Strict Standards: Non-static method Soojung::addReferer() should not be called statically in /home/lifthrasiir/sites/sapzil.info/soojung/settings.php on line 79

Warning: Cannot modify header information - headers already sent by (output started at /home/lifthrasiir/sites/sapzil.info/soojung/settings.php:79) in /home/lifthrasiir/sites/sapzil.info/soojung/classes/Counter.class.php on line 63

Strict Standards: Non-static method Entry::getEntry() should not be called statically in /home/lifthrasiir/sites/sapzil.info/soojung/entry.php on line 51

Strict Standards: Non-static method Soojung::entryIdToFilename() should not be called statically in /home/lifthrasiir/sites/sapzil.info/soojung/classes/Entry.class.php on line 182

Strict Standards: Non-static method Soojung::queryFilenameMatch() should not be called statically in /home/lifthrasiir/sites/sapzil.info/soojung/classes/Soojung.class.php on line 55
TokigunStudio3 | 블로그: 파이썬으로 장난치기_-_

내용으로 바로 넘어 가기


TokigunStudio3

228 / 3282   


더 이상 이 블로그는 운영되지 않습니다. 새 블로그로 가 주세요.

파이썬으로 장난치기_-_

2004/11/08 AM 09:02 | 개발/파이썬 | 3 comments | 0 trackbacks | AllBlog: vote, to pocket

http://www.likejazz.com/29500.html을 보고 생각나서 만든 프로그램... -_-;;; 저기 있는 0과 1들로 이루어진 숫자들을 "조작 없이 그냥" 아래의 (여기)에 붙여 넣고 실행시키면 된다.

print''.join((lambda o=''.join("""(여기)""".split()):[eval(r"'\x%02x'"%(reduce(lambda x,y:(x<<1)|"01".find(y),o[z<<3:][:1<<3],0)))for z in xrange(len(o)>>3)])())

작은 프로그램이지만 들어 있을 건 다 들어 있다. -_-; 여기서 배울 수 있는 것들을 모아 보면:

- print 문의 사용
- 문자열의 종류("""..."""나 r"..." 같은 것도 포함)와 escape sequence-_-
- 문자열에 있는 메소드들 (join, split, find)
- 문자열 슬라이싱하기
- len, eval, reduce 함수
- 리스트 해석 (list comprehension)
- 비트 연산-,.-;;
- lambda 문의 사용과 기본 인수 사용
- 함수 호출
- xrange 객체
- "문자열 % 변수" 꼴의 문장 사용 (이게 sprintf..)
- 그 외에 이런 류의 obfuscated source code를 해석할 수 있는 능력 -_-;;;;;;;;;;

이 프로그램을 성공적으로 해석할 수 있다면 적어도 파이썬에 얼마정도 익숙하다는 걸 증명할 수 있을 것이라 생각한다. :) (물론 프로그램 자체는 쉽지만...) ...너무 깊게 생각했나;;;

TrackBack URL: http://sapzil.info/soojung/trackback.php?blogid=177

Comment: falsetru (2004/11/08 PM 02:11)

Ruby로..

puts <<BINSTR.split.join.scan(/.{8}/).map{|x|x.to_i(2).chr}.join
~여기~
BINSTR

Comment: falsetru (2004/11/08 PM 02:18)

Ruby로.. =3

puts [<<BINSTR.split.join].pack('B*')
~여기~
BINSTR

Comment: 토끼군 (2004/11/08 PM 02:19)

falsetru: 오... scan 메소드가 맘에 드네요. 흐흐흐.

Copyright (c) 1995-2005, Kang Seonghoon (Tokigun).