1 2 3 

요즘 소일꺼리로 보고 있는 vi 서적, 나중에 또 볼일이 생길 수도 있어서 올려 놓는다.
크리에이티브 커먼즈 라이센스
Creative Commons License
Writer profile
author image
블로그 바깥 쥔장입니다.
지우, 민정 두 아이의 평범한 초보 아빠입니다.
2008/09/11 01:38 2008/09/11 01:38
Posted by 깜장여우™
관심꺼리들/General Programming l 2008/09/11 01:38

오늘은 SVN + apache  조합에서 권한 설정을 하려고 합니다.

프로젝트들 마다 Core 로직과 App 부분으로 나뉘어집니다. SVN을 통해서 특정 ID는 특정 구역에 접근하지 못하도록 설정하고 싶은데, 이 부분의 세팅을 하고 싶을 껍니다.

여기서  SVN 설치를 성공을 했다면, 이제 세팅을 해봅시다.

뭐 일단 간단 합니다. http.conf 파일을 수정합니다.

<VirtualHost *:80>
    ServerAdmin webmaster@darkfox.info
    ServerName svn.darkfox.info
    ErrorLog logs/svn.darkfox.info-error_log
    CustomLog logs/svn.darkfox.info-access_log common

    <Location />
        DAV svn
        SVNPath c:/svn
# 여러개의 프로젝트를 등록할꺼면 SVNPath 대신 SVNParentPath를 사용하세요.
#        SVNListParentPath on
#        SVNParentPath c:\svn
           
        AuthType Basic
        AuthName "Subversion repository"
        AuthUserFile c:/svn/conf/htpasswd
        AuthzSVNAccessFile c:/svn/conf/authz
    #    <LimitExcept GET PROPFIND OPTIONS REPORT>
    #        Require valid-user
    #    </LimitExcept>

        Require valid-user
    </Location>

</VirtualHost>

잘 했는지 봅시다.
http://svn.darkfox.info 를 경로로 사용하겠습니다.

SVNParentPath 를 사용했다면
http://svn.darkfox.info/만든프로젝트폴더 를 사용하시면 됩니다
예를 들면
http://svn.darkfox.info/test-svn 이런식이죠.

SVN 서버에 c:\svn\conf 에 있는 authz 파일을 수정합니다

[groups]
admin = darkfox
devteam = user2
tester = user1
anonymous =

[/]
#그룹으로 처리해도 되고
@admin = rw

[/core]
#읽기전용
@devteam = r
#접근금지
@tester =

[test-svn:/]
#ID를 직접 써도 됩니다.
darkfox = rw

샘플로 만든 파일입니다. 

SVN에 만들어진 경로들을 적당히 등록해주시면 하위 디렉토리들은 자동으로 적용됩니다.
다음엔 HTTPS를 이용한 SSL 보안과 SVN에 대해 다뤄보도록 하겠습니다.

궁금한건 댓글을 달아주시면 짬나는대로 답변해드리겠습니다.

크리에이티브 커먼즈 라이센스
Creative Commons License
Writer profile
author image
블로그 바깥 쥔장입니다.
지우, 민정 두 아이의 평범한 초보 아빠입니다.
2008/05/16 23:42 2008/05/16 23:42
Posted by 깜장여우™
관심꺼리들/General Programming l 2008/05/16 23:42
TAG ,

중학교때 처음으로 시작한 프로그램 언어이다...

아직도 이런거 쓰는 곳이 있을까??

나중에 필요할지도 몰라서 일단은 올려 둔다...

 
크리에이티브 커먼즈 라이센스
Creative Commons License
Writer profile
author image
블로그 바깥 쥔장입니다.
지우, 민정 두 아이의 평범한 초보 아빠입니다.
2007/11/20 22:22 2007/11/20 22:22
Posted by 깜장여우™
관심꺼리들/General Programming l 2007/11/20 22:22

프로그래머지만 가끔은 const의 역활을 헤깔릴때가 많다. 그래서 뭐 몇가지 정리해 놓는다.

다음과 같은 class가 있다.
a *= b; 와 같은 형태의 일을 하는 class 이다.


 

class AccNumber
{
public:
    void SetValue( int v )
    {
        value = v;
    }


    int GetValue() const
    {
        return value;
    }


    const AccNumber& Multiply( const AccNumber& a )
    {
        value = value * a.value;
        return *this;
    }


private:
    int value;
};

   
void main()
{
    AccNumber a, b, c;

    a.SetValue( 10 );
    b.SetValue( 20 );
    c.SetValue( 30 );


    a.Multiply( b );
    a.Multiply( c );

}


이곳에 표현된 const를 분석해 보자.

1. SetValue은 자신의 멤버 변수를 변경하기에
      void SetValue( int v ) const; 라고 쓰지 않는다.

2. int GetValue() const; 은 자신의 멤버 변수를 변경하지 않기에 const를 붙였다.
       혹여나 변경하려고 하면 컴파일타임 에러를 유발한다.

3. const AccNumber& Multiply( const AccNumber& a );
  1) 자신의 멤버를 변경하기에 뒤에 const를 붙이지 않았다.
  2) 입력 값은 변경되지 않기에 ( const AccNumber& a ); 처럼 const를 붙였다.
  3) 그 결과 값이 변경되길 바라지 않기에 return type으로 const를 붙였다.

크리에이티브 커먼즈 라이센스
Creative Commons License
Writer profile
author image
블로그 바깥 쥔장입니다.
지우, 민정 두 아이의 평범한 초보 아빠입니다.
2007/11/16 11:05 2007/11/16 11:05
Posted by 깜장여우™
관심꺼리들/General Programming l 2007/11/16 11:05

 

UnitTest++ in brief

Introduction

This little document serves as bare-bones documentation for UnitTest++.

For background, goals and license details, see:

The documentation, while sparse, aims to be practical, so it should give you enough info to get started using UnitTest++ as fast as possible.

Building UnitTest++

Building UnitTest++ will be specific to each platform and build environment, but it should be straightforward.

Building with Visual Studio

If you are using Visual Studio, go for either of the provided .sln files, depending on version. There are no prefabricated solutions for versions earlier than VS.NET 2003, but we have had reports of people building UnitTest++ with at least VS.NET 2002.

Building with Make

The bundled makefile is written to build with g++. It also needs sed installed in the path, and to be able to use the mv and rm shell commands. The makefile should be usable on most Posix-like platforms.

Do "make all" to generate a library and test executable. A final build step runs all unit tests to make sure that the result works as expected.

Packaging

You'll probably want to keep the generated library in a shared space in source control, so you can reuse it for multiple test projects. A redistributable package of UnitTest++ would consist of the generated library file, and all of the header files in UnitTest++/src/ and its per-platform subfolders. The tests directory only contains the unit tests for the library, and need not be included.

Using UnitTest++

The source code for UnitTest++ comes with a full test suite written using UnitTest++. This is a great place to learn techniques for testing. There is one sample .cpp file: UnitTest++/src/tests/TestUnitTest++.cpp. It covers most of UnitTest++'s features in an easy-to-grasp context, so start there if you want a quick overview of typical usage.

Getting started

Listed below is a minimal C++ program to run a failing test through UnitTest++.

  // test.cpp
  #include <UnitTest++.h>

  TEST(FailSpectacularly)
  {
    CHECK(false);
  }

  int main()
  {
    return UnitTest::RunAllTests();
  }

UnitTest++.h is a facade header for UnitTest++, so including that should get you all features of the library. All classes and free functions are placed in namespace UnitTest, so you need to either qualify their full names (as with RunAllTests() in the example) or add a using namespace UnitTest; statement in your .cpp files. Note that any mention of UnitTest++ functions and classes in this document assume that the UnitTest namespace has been opened.

Compiling and linking this program with UnitTest++'s static library into an executable, and running it, will produce the following output (details may vary):

  .\test.cpp(5): error: Failure in FailSpectacularly: false
  FAILED: 1 out of 1 tests failed (1 failures).
  Test time: 0.00 seconds.

UnitTest++ attempts to report every failure in an IDE-friendly format, depending on platform (e.g. you can double-click it in Visual Studio's error list.) The exit code will be the number of failed tests, so that a failed test run always returns a non-zero exit code.

Test macros

To add a test, simply put the following code in a .cpp file of your choice:

  TEST(YourTestName)
  {
  }

The TEST macro contains enough machinery to turn this slightly odd-looking syntax into legal C++, and automatically register the test in a global list. This test list forms the basis of what is executed by RunAllTests().

If you want to re-use a set of test data for more than one test, or provide setup/teardown for tests, you can use the TEST_FIXTURE macro instead. The macro requires that you pass it a class name that it will instantiate, so any setup and teardown code should be in its constructor and destructor.

  struct SomeFixture
  {
    SomeFixture() { /* some setup */ }
    ~SomeFixture() { /* some teardown */ }

    int testData;
  };
 
  TEST_FIXTURE(SomeFixture, YourTestName)
  {
    int temp = testData;
  }

Note how members of the fixture are used as if they are a part of the test, since the macro-generated test class derives from the provided fixture class.

Suite macros

Tests can be grouped into suites, using the SUITE macro. A suite serves as a namespace for test names, so that the same test name can be used in two difference contexts.

  SUITE(YourSuiteName)
  {
    TEST(YourTestName)
    {
    }

    TEST(YourOtherTestName)
    {
    }
  }

This will place the tests into a C++ namespace called YourSuiteName, and make the suite name available to UnitTest++. RunAllTests() can be called for a specific suite name, so you can use this to build named groups of tests to be run together.

Simple check macros

In test cases, we want to check the results of our system under test. UnitTest++ provides a number of check macros that handle comparison and proper failure reporting.

The most basic variety is the boolean CHECK macro:

  CHECK(false); // fails

It will fail if the boolean expression evaluates to false.

For equality checks, it's generally better to use CHECK_EQUAL:

  CHECK_EQUAL(10, 20); // fails
  CHECK_EQUAL("foo", "bar"); // fails

Note how CHECK_EQUAL is overloaded for C strings, so you don't have to resort to strcmp or similar. There is no facility for case-insensitive comparison or string searches, so you may have to drop down to a plain boolean CHECK with help from the CRT:

  CHECK(std::strstr("zaza", "az") != 0); // succeeds

For floating-point comparison, equality isn't necessarily well-defined, so you should prefer the CHECK_CLOSE macro:

  CHECK_CLOSE(3.14, 3.1415, 0.01); // succeeds

All of the macros are tailored to avoid unintended side-effects, for example:

  TEST(CheckMacrosHaveNoSideEffects)
  {
    int i = 4;
    CHECK_EQUAL(5, ++i); // succeeds
    CHECK_EQUAL(5, i); // succeeds
  }

The check macros guarantee that the ++i expression isn't repeated internally, as demonstrated above.

Array check macros

There is a set of check macros for array comparison as well:

  const float oned[2] = { 10, 20 };
  CHECK_ARRAY_EQUAL(oned, oned, 2); // succeeds
  CHECK_ARRAY_CLOSE(oned, oned, 2, 0.00); // succeeds

  const float twod[2][3] = { {0, 1, 2}, {2, 3, 4} };
  CHECK_ARRAY2D_CLOSE(twod, twod, 2, 3, 0.00); // succeeds

The array equal macro compares elements using operator==, so CHECK_ARRAY_EQUAL won't work for an array of C strings, for example.

The array close macros are similar to the regular CHECK_CLOSE macro, and are really only useful for scalar types, that can be compared in terms of a difference between two array elements.

Note that the one-dimensional array macros work for std::vector as well, as it can be indexed just as a C array.

Exception check macros

Finally, there's a CHECK_THROW macro, which asserts that its enclosed expression throws the specified type:

  struct TestException {};
  CHECK_THROW(throw TestException(), TestException); // succeeds

UnitTest++ natively catches exceptions if your test code doesn't. So if your code under test throws any exception UnitTest++ will fail the test and report either using the what() method for std::exception derivatives or just a plain message for unknown exception types.

Should your test or code raise an irrecoverable error (an Access Violation on Win32, for example, or a signal on Linux), UnitTest++ will attempt to map them to an exception and fail the test, just as for other unhandled exceptions.

Time constraints

UnitTest++ can fail a test if it takes too long to complete, using so-called time constraints.

They come in two flavors; local and global time constraints.

Local time constraints are limited to the current scope, like so:

  TEST(YourTimedTest)
  {
     // Lengthy setup...

     {
        UNITTEST_TIME_CONSTRAINT(50);

        // Do time-critical stuff
     }

     // Lengthy teardown...
  }

The test will fail if the "Do time-critical stuff" block takes longer than 50 ms to complete. The time-consuming setup and teardown are not measured, since the time constraint is scope-bound. It's perfectly valid to have multiple local time constraints in the same test, as long as there is only one per block.

A global time constraint, on the other hand, requires that all of the tests in a test run are faster than a specified amount of time. This allows you, when you run a suite of tests, to ask UnitTest++ to fail it entirely if any test exceeds the global constraint. The max time is passed as a parameter to an overload of RunAllTests().

If you want to use a global time constraint, but have one test that is notoriously slow, you can exempt it from inspection by using the UNITTEST_TIME_CONSTRAINT_EXEMPT macro anywhere inside the test body.

  TEST(NotoriouslySlowTest)
  {
     UNITTEST_TIME_CONSTRAINT_EXEMPT();

     // Oh boy, this is going to take a while
     ...
  }

Test runners

The RunAllTests() function has an overload that lets you customize the behavior of the runner, such as global time constraints, custom reporters, which suite to run, etc.

  int RunAllTests(TestReporter& reporter, TestList const& list, char const* suiteName, int const maxTestTimeInMs);

If you attempt to pass custom parameters to RunAllTests(), note that the list parameter should have the value Test::GetTestList().

The parameterless RunAllTests() is a simple wrapper for this one, with sensible defaults.

Example setup

How to create a new test project varies depending on your environment, but here are some directions on common file structure and usage.

The general idea is that you keep one Main.cpp file with the entry-point which calls RunAllTests().

Then you can simply compile and link new .cpp files at will, typically one per test suite.

   + ShaverTests/
   |
   +- Main.cpp
   |
   +- TestBrush.cpp   
   +- TestEngine.cpp
   +- TestRazor.cpp   

Each of the Test*.cpp files will contain one or more TEST macro incantations with the associated test code. There are no source-level dependencies between Main.cpp and Test*.cpp, as the TEST macro handles the registration and setup necessary for RunAllTests() to find all tests compiled into the same final executable.

UnitTest++ does not require this structure, even if this is how the library itself does it. As long as your test project contains one or more TESTs and calls RunAllTests() at one point or another, it will be handled by UnitTest++.

It's common to make the generated executable start as a post-build step, so that merely building your test project will run the tests as well. Since the exit code is the count of failures, a failed test will generally break the build, as most build engines will fail a build if any step returns a non-zero exit code.

크리에이티브 커먼즈 라이센스
Creative Commons License
Writer profile
author image
블로그 바깥 쥔장입니다.
지우, 민정 두 아이의 평범한 초보 아빠입니다.
2007/11/14 11:32 2007/11/14 11:32
Posted by 깜장여우™
관심꺼리들/General Programming l 2007/11/14 11:32

이것이 버그 같지는 않지만 사용해보니 VS2005의 STL에서는(VS2003에서도 그런지는 잘 모르겠슴) 디버그 빌드에서 속도가 엄청나게 느려졌다.
따라 들어 가보니 debug모드에서는 런타임에서 컨테이너의 range체크를 한다.
이걸 해제할려면

#define _HAS_ITERATOR_DEBUGGING 0

이나 컴파일 옵션에서

-D_HAS_ITERATOR_DEBUGGING

와 같이 하면 릴리즈모드와 비슷한 속도가 난다. 물론.. 이제부터는 죽는 버그들에서 스스로 책임을 져야 함... ^^;

크리에이티브 커먼즈 라이센스
Creative Commons License
Writer profile
author image
블로그 바깥 쥔장입니다.
지우, 민정 두 아이의 평범한 초보 아빠입니다.
2007/11/14 11:26 2007/11/14 11:26
Posted by 깜장여우™
관심꺼리들/General Programming l 2007/11/14 11:26
TAG

윈도우에 subversion 서버를 설치하는 방법입니다. 아파치를 이용하면 http 프로토콜을 사용해서 외부에서도 버전 컨트롤을 할 수 있는 장점이 있습니다.

가급적 폴더를 바꾸지 않고 설치했다면 다음과 같은 폴더와 같이 됩니다.

Apache = C:\Program Files\Apache Group\Apache2
Subversion = C:\Program Files\Subersion
Location of Repositories: C:\svn\
Location of passfile: C:\svn.pass
URL for Repositories: http://localhost:8080/svn/

1. 아파치 설치

a.  http://httpd.apache.org/download.cgi에서 다운 받으세요. (저는참고로 2.0.59를 사용하고 있습니다. )

b. 다운받으신 파일을 설치하세요. 옵션은 디폴트로 설치하면 됩니다. 보통 KT나 하나로통신같은 경우는 80 포트를 지원하지 않으므로 포트는 나중에 바꿔야 합니다만. 지금은 그냥 넘어가겠습니다. 계속 진행해서 설치까지 완료!!!

c. 혹시나 윈도우 서버를 사용하시면 IIS 가 이미 80 포트에서 실행중일수 도 있겠군요. C:\Program Files\Apache Group\Apache2\conf\httpd.conf  파일을 메모장에서 여시고 "listen" 이라는 글자를 찾으세요

Code:
Listen 80


자 이제 때가 왔습니다. 80을 8080 으로 바꾸겠습니다.

d. http.conf 파일을 저장하고 변경된 사항을 반영하기 위해서 아파치를 리스타트 하겠습니다.  화면 오른쪽 아래 시계 옆에 트레이 아이콘에 이미 아파치 아이콘이 있을껍니다. 그녀석을 클릭하면 메뉴가 나옵니다. (Start / Stop/ Restart) 중에서 당연히 Restart 겠죠.

e. 인터넷 익스플로러를 열고 http://localhost:8080/ 를 주소에 넣어 보시죠.. 화면에 뭔가 뜨면. 잘 하신겁니다.

2.  SUBVERSION 설치

a. 윈도우용 서브버전 서버를 다운 받습니다.  http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=91
(현재는
svn-1.4.3-setup.exe 이군요..)

b. 셋업 파일을 실행하고 디폴트로 설치해주시면 됩니다.
요기까지 설치는 완료..

3. 아파치에 서브버전 모듈 설정

a. C:\Program Files\Apache Group\Apache2\conf\httpd.conf 파일을 다시 메모장으로 열어봅시다.
맨 아래중에 다음과 같이 추가해줍니다.



<Location /svn>
DAV svn
SVNParentPath  C:\svn
AuthType Basic
AuthName "Subversion repositories"
AuthUserFile C:\svn.pass
Require valid-user
</Location>


c. 아까처럼 아파치를 다시 재부팅 해줍니다.

d. http://localhost:8080/svn/ 주소로 들어가시면 이번에는 암호를 물어보는 창이 뜹니다. 아직 ID나 Passwd가 없으므로 살포시 cancel을 눌러 줍니다.

4. 사용자ID와 암호 생성

a. Apache2/bin 에 있는 htpasswd.exe 를 이용해서 패스워드 파일을 수정하도록 하죠. 보통은 접근이 안되니 (내 컴퓨터 -> 고급-> 환경변수) PATH 에: ;C:\Program Files\Apache Group\Apache2\bin 를 추가해줍니다.

b. 비어있는 C:\svn.pass 파일을 하나 추가합니다.

c. DOS창을 하나 열어서

d. C:\ 로 가신후에

Code:
c:\> htpasswd svn.pass svnuser(사용할ID)


패스워드를 물어 볼 겁니다. 잘 넣으세요

e. svn.pass 파일을 열어보시면, "svnuser" 이라는 항목과 알수없는 스트링이 추가되어 있으면 성공입니다.

5. 저장소 만들기

a. 탐색기에서
C:\svn 폴더를 하나 만듭니다. 

b. DOS 창을 하나 열어서 c:\svn 으로 옮기신후

c. 아래와 같이 쓰세요:

Code:
svnadmin create myrepository(사용할 저장소 이름)


d. 인터넷 탐색기를 열어서  http://localhost:8080/svn/myrepository/ 주소를 치신후  username/pass 를 입력하시면 "Revision 0" 라고 보이면 성공입니다.

6. 좀 더 편리한 내용으로..

저같은 경우는  TortoiseSVN http://tortoisesvn.tigris.org/ 을 추천합니다. DOS창 좋아하시면 쓰셔도 되지만 보통 탐색기를 많이 쓰실테니 애드온 하나쯤은 사용하시는게 좋습니다.
크리에이티브 커먼즈 라이센스
Creative Commons License
Writer profile
author image
블로그 바깥 쥔장입니다.
지우, 민정 두 아이의 평범한 초보 아빠입니다.
2007/05/26 22:34 2007/05/26 22:34
Posted by 깜장여우™
관심꺼리들/General Programming l 2007/05/26 22:34

개발할때 필요한 프로그램입니다.

뭔가 실행할때 나타나는 디버그 메세지들을 볼 수 있는 프로그램입니다.

인터넷가면 많이 다운 받을 수 있는 프로그램인것 같네요.. ^^/




나중에 기억해 두려고 올려 둡니다.
크리에이티브 커먼즈 라이센스
Creative Commons License
Writer profile
author image
블로그 바깥 쥔장입니다.
지우, 민정 두 아이의 평범한 초보 아빠입니다.
2007/05/10 12:07 2007/05/10 12:07
Posted by 깜장여우™
관심꺼리들/General Programming l 2007/05/10 12:07
TAG

아래 4문제를 풀어,12월09일(금) 오후 2시까지

*******@nexon.co.kr로 전달 해주시면 됩니다.

기한내 미 제출시, 자동으로 탈락처리 됩니다.

아울러, 정답은 메일내용에 기재하신 후 소스와 함께 첨부 부탁드립니다.

기타 문의사항은 02-2185-****로 연락부탁드립니다.







========================== 과제물================================================



다음 네 문제는 컴퓨터로 알고리즘을 작성하여 풀 수 있는 문제입니다.

(프로그래밍 언어는 C++ 또는 C를 사용하셔야 합니다.)

네 문제 모두 단답형이므로, 풀이 과정이나 설명을 적을 필요는 없고,

답을 적고 작성한 프로그램 소스 파일을 첨부해서 보내주시면 됩니다.

또, 넥슨에서 본 문제 메일을 발송한 시점에서 만 이틀이 지나기 전에

귀하의 답이 넥슨에 도착하지 않으면 불합격이며 보내주신 소스 파일은 채용 과정에서 검토됩니다.



문제의 설명과 예는 답을 구하기에 충분하므로, 추가적인 질문은 받지 않습니다.





1번 설명



어떤 자연수 n이 있을 때, d(n)을 n의 각 자릿수 숫자들과 n 자신을 더한 숫자라고 정의하자.
예를 들어 d(91) = 9 + 1 + 91 = 101
이 때, n을 d(n)의 제네레이터(generator)라고 한다. 위의 예에서 91은 101의 제네레이터이다.
어떤 숫자들은 하나 이상의 제네레이터를 가지고 있는데, 101의 제네레이터는 91 뿐 아니라 100도 있다.
그런데 반대로, 제네레이터가 없는 숫자들도 있으며, 이런 숫자를 인도의 수학자 Kaprekar가

셀프 넘버(self-number)라 이름 붙였다.
예를 들어 1,3,5,7,9,20,31 은 셀프 넘버 들이다.









1번 문제



1 이상이고 5000 보다 작은 모든 셀프 넘버들의 합을 구하라.



1번 답 : ________









2번 설명



가로 세로의 네모 칸들로 이루어진 방에 총잡이들이 있다고 하자.
총잡이들은 가로 혹은 세로 방향으로 다른 총잡이가 보이면 총격전을 벌여 한 쪽만 살아 남는다.
칸 중에는 벽으로 막힌 곳이 있어서 총잡이들이 벽 너머로는 볼 수 없으며, 대각선 방향도 볼 수 없게 되어 있다.



■: 벽
□: 빈 칸
♂: 총잡이



에를 들어, 다음과 같은 가로 세로 네 칸 씩으로 된 방이 있다고 하면,



■■■□
□□□□
□■□□
■■■□



총잡이 세 명을 다음과 같이 배치해볼 수 있을 것이다.



■■■□
□□□♂
♂■♂□
■■■□



가로 혹은 세로 방향에서 다른 총잡이에 노출되는 총잡이는 어느 한쪽이라도 죽게 되므로,
다음과 같은 배치는 할 수 없다.



■■■□
□♂□♂
□■□□
■■■□



위와 같이 생긴 방에 최대한 많은 총잡이를 배치하는 경우, 최대 네 명까지 가능하며,
네 명을 배치하는 경우의 수는 다음과 같은 두 가지 방법이 존재한다.



■■■♂
□♂□□
♂■♂□
■■■□





■■■□
□♂□□
♂■♂□
■■■♂



또 한가지 예로, 만약 벽이 전혀 없는 가로 세로 네 칸씩으로 된 방이 있다면,

최대 네 명의 총잡이를 24 가지의 방법으로 배치할 수 있을 것이다.







2번 문제



다음과 같이 생긴 가로 세로 여덟 칸씩으로 된 방에는 최대 몇 명의 총잡이를 배치할 수 있으며,

그 경우, 몇 가지 방법으로 배치할 수 있겠는가?



□■□■□■□■
□□□□□■□□
■□■□□■□■
□□□□□□□□
□□□■□□□□
□□□□□■□■
□■□□□□□□
□□□□■□■□



2번 답 : 최대 ____ 명, ____ 가지.







3번 설명



RLE(Run Length Encoding)란, 임의의 수열을 (반복 수, 숫자)의 쌍으로 된 수열로 만드는 부호화 방법이다.
예를 들어 다음과 같은 열 개의 숫자로 된 수열이 있다고 할 때,

9, 9, 9, 5, 7, 7, 7, 7, 7, 7

RLE를 이용하여 다음과 같이 여섯 개의 숫자로 부호화할 수 있다.

(3,9), (1,5), (6,7)



해석하면, 9가 세 개 있고, 그 다음에 5가 한 개, 그 다음에 7이 여섯 개 나오는 수열이라는 뜻이다.

이 때, (원래 수열의 갯수) / (부호화 수열의 갯수) 를 압축률이라 하며, 위의 경우에서 압축률은 10 / 6 = 1.666 이다.
이렇게 부호화된 값은 쉽게 원래 값으로 복원할 수 있음을 알 수 있을 것이다.



그런데, 원래 값으로 되돌리는 것을 보장하지 않는 RLE 방법을 '손실 RLE'라 하자.
이 경우는 복원했을 때 오차가 생기게 되는데, 원래 수열과의 RMSE (Root Mean Square Error) 를 오차로서 정의한다.
크기가 n인 A 수열과 B 수열 사이의 RMSE는 다음과 같이 계산한다



RMSE(A,B) = sqrt( ( (A1-B1)^2 + (A2-B2)^2 + ... + (An-Bn)^2 ) / n)



'손실 RLE' 방법은 다양하게 존재하므로, 같은 수열이라도 다양하게 '손실 RLE' 부호화 할 수 있는데,



예를 들어, 위와 같은 수열의 경우
(10,9) 혹은, (10, 7) 혹은 (3, 9), (7, 7) 등으로 '손실 RLE' 부호화할 수 있을 것이다.



만약 (10,9) 으로 부호화했다면, 압축률은 5 이며, RMSE는 2 이다.
(10,7) 로 부호화했다면, 압축률은 5 이며, RMSE는 1.26 이다.
(3,9), (7,7) 로 부호화했다면, 압축률은 2.5 이며, RMSE는 0.63 이다.







3번 문제



다음과 같이 128개의 정수로 된 수열이 있을 때,



49, 49, 50, 52, 49, 47, 47, 46, 44, 42, 42, 38, 38, 38, 36, 34,
33, 33, 33, 32, 34, 38, 42, 41, 42, 42, 40, 41, 40, 38, 38, 37,
37, 39, 41, 40, 40, 40, 40, 42, 45, 47, 47, 46, 46, 46, 47, 47,
47, 47, 46, 44, 43, 39, 36, 34, 34, 32, 30, 29, 30, 31, 31, 31,
30, 28, 25, 23, 24, 22, 22, 25, 25, 27, 31, 33, 35, 37, 38, 39,
39, 40, 40, 41, 40, 40, 40, 40, 39, 38, 37, 35, 35, 34, 33, 32,
31, 30, 30, 29, 29, 28, 27, 27, 28, 27, 25, 26, 0, 0, 90, 90,
90, 90, 90, 91, 90, 88, 87, 84, 80, 78, 83, 89, 91, 90, 89, 92



오차를 가능한 한, 작게 억제하면서 32개의 정수(압축률 4)로 압축하는

자신만의 '손실 RLE' 알고리듬을 만들고, 그 알고리듬에 의한 부호화 결과 수열과 RMSE를 적어라.
(RMSE 가 1.8 미만이면 정답으로 간주하며, RMSE가 1.6보다 작을 수록 가산점 있음.)



주의; 답은 정확히 32개의 정수로 나와야 하며 32개보다 적거나 많으면 오답으로 처리 됩니다.

오답 예 1)

( 8, 49), ( 3, 44), ( 5, 38), ( 5, 33), ( 1, 38), ( 8, 42), ( 6, 38), ( 4, 40),

( 8, 45), ( 4, 47), ( 1, 43), ( 1, 39), ( 3, 36), ( 2, 32), ( 7, 29), ( 3, 25),

( 3, 22), ( 2, 25), ( 2, 31), ( 2, 35), ( 5, 38), ( 7, 41), ( 3, 37), ( 3, 34),

( 5, 31), ( 7, 28), ( 2, 0 ), ( 9, 90), ( 1, 84), ( 2, 80), ( 1, 83), ( 5, 89)

-> 64개의 정수로 오답

오답 예 2)

(8, 47), (7, 38), (6, 33), (8, 42), (11, 40), (14, 47), (12, 31), (8, 24)

(20, 39), (8,30), (6, 26), (2, 0), (9, 90), (1, 84), (8, 83)

-> 30개의 정수로 오답



3번 답



(__, __), (__, __), (__, __), (__, __), (__, __), (__, __), (__, __), (__, __),
(__, __), (__, __), (__, __), (__, __), (__, __), (__, __), (__, __), (__, __)



RMSE = ____









4번 설명


다음과 같은 배열(array)이 있다고 가정할 때
A = { 30, 1, 18, 2, 5, 10, 15, 9, 5, 25, 5 }
B = { 2, 4, 11, 5, 24, 18, 8, 4, 13, 18 }
:*: 는
"A 배열과 B 배열에 동시에 존재하는 수의 갯수를 구하는 연산" 이고
|*| 는
"A 배열과 B 배열에 동시에 존재하는 수의 집합(set)의 크기를 구하는 연산"이라고 정의하면

A :*: B = 9 이고 ( A' = { 18, 2, 5, 5, 5 }, B' = { 2, 5, 18, 18 } )
A |*| B = 3 이다. ( { 2, 5, 18 } )







4번 문제


첨부된 Problem4Data.exe를 실행하면 work folder에 array1.dat, array2.dat 파일이
생성되며 각 파일의 크기는 4GByte 이다. ( 실행 전 디스크 용량 체크 필요 )

각 파일은 64 bit unsigned integer 값이 Little Endian 형식으로 차례로 기록되어
있으며 해당 array 내용은 다음과 같다.

array1.dat =

{

0b9cba234dfa382b, 39a3a0d4d852f190, b9327f793917ff50, 1616a4aabd698224
...

fa042ea941e23e5f, 3b822f8e29debd79, 10c3149ac586d931, ff7010cd11748990

}



array2.dat =


{

c801c1d4fa7aa667, 354950b8ddf236d5, b2cd486f07bf5480, 87bd78f1a50ce1e8

...
751cb8fad5eb894e, b0e9830fdf5b86d4, fc0a9158f62abfc6, 4f178f9413158f9c

}

array1 = A, array2 = B 라고 했을 때
A :*: B 값과
A |*| B 값을 구하여라.

4번 답 : A :*: B 값 __________ , A |*| B 값 __________



참조 : http://orbi7.com/bbs/zboard.php?id=pls_amu_imported&no=20076

훔.. 많은 생각을 하게 되긴 하네요...  저도 좀 순간 어리둥절~~~
크리에이티브 커먼즈 라이센스
Creative Commons License
Writer profile
author image
블로그 바깥 쥔장입니다.
지우, 민정 두 아이의 평범한 초보 아빠입니다.
2007/04/06 00:10 2007/04/06 00:10
Posted by 깜장여우™
관심꺼리들/General Programming l 2007/04/06 00:10