출처) http://www.pythonchallenge.com/index.php
The Python Challenge
What people have said about us: "These sorts of things are in my opinion the best way to learn a language.", brberg at Media Cloisters "It's the best web site of the year so far.", Andy Todd at halfcooked "Addictive way to learn the ins and outs of Python.
www.pythonchallenge.com
http://www.pythonchallenge.com/pc/def/channel.html
- 파이썬 챌린지 레벨6 문제!
- 주어진 것은 바지지퍼 사진과 밑에 paypal 로고뿐이다.
- 바로 페이지소스를 확인해보았다.
- 상단에 주석으로 zip이라고 적혀있다.
- 이미지가 지퍼였으니까 zip과 관련이 있는 건가...
- 하단에도 주석이 있다.
" The following has nothing to do with the riddle itself.
I just thought it would be the right point to offer you to donate to the Python Challenge project.
Any amount will be greatly appreciated."
다음은 수수께끼 그 자체와는 아무런 관계가 없다. 파이썬 챌린지 프로젝트에 기부하자고 제안하는 게 적절한 시점이라고 생각했을 뿐이다. 어떤 금액이라도 크게 고마워할 것이다.
- 도움이 되는 힌트는 아닌 것 같다. 그리고 paypal에 관한 문제도 아닌 것 같다.
- 아까 주석에 zip이라고 나와있었으니까 url주소를 zip으로 바꾸어 보았다.
- http://www.pythonchallenge.com/pc/def/channel.zip
- channel.zip파일이 다운 받아진다.
- 엄청나게 많은 숫자 파일명을 가진 txt파일들이 있다.
- 제일 밑에 readme.txt파일을 열어보았다.
- readme.txt파일 안에는 힌트 2개가 적혀 있었다.
- 첫번째 힌트는 90052부터 시작이라고 적혀 있고, 두번째 힌트는 답은 zip파일 안에 있다고 한다.
- 저번 파이썬 챌린지 레벨 4 문제와 비슷한 것 같아 저번에 구현했던 걸 활용했다.
import zipfile
import re
file=zipfile.ZipFile("D:/Python Challenge/channel.zip")
num="90052"
while True:
data=file.read(num+".txt").decode('utf-8')
pattern="Next nothing is (\d+)"
found=re.findall(pattern,data)
if found :
num=" ".join(found)
print(data)
else:
print(data)
break
- 저번 구현한 것에서 바꾼 것은 data변수이다. 저번엔 uri를 열어서 %에 num변수를 넣는 거였다면 이번껀 zipfile 모듈을 사용하여 txt앞에 num변수를 넣어 파일을 읽어오는 것이다.
- 패턴 또한 저번 것과 똑같다. 이렇게 구현하여 출력하면 아래와 같은 숫자들이 나온다.
- 마지막은 46145.txt파일이다. 여기가 끝인 줄 알았으나 아니였다.
"Collect the comments."
주석을 모아라
[그림3]을 보면 오른쪽 파일 설명에 문자들이 적힌 걸 볼 수 있다.
아까 출력한 숫자 순서로 주석을 모으는 것 같다.
import zipfile
import re
file=zipfile.ZipFile("D:/Python Challenge/channel.zip")
num="90052"
result = ''
while True:
data=file.read(num+".txt").decode('utf-8')
pattern="Next nothing is (\d+)"
found=re.findall(pattern,data)
result=result + file.getinfo(num+".txt").comment.decode('utf-8')
if found :
num=" ".join(found)
print(data)
else:
print(data)
break
print(result)
- zipfile 모듈을 찾아보니 comment를 출력하는 기능이 있었다.
- 아카이브 파일에 대한 정보는 .getinfo()를 사용하면 된다.
답 : HOCKEY(이게 끝이 아님...)
http://www.pythonchallenge.com/pc/def/hockey.html 로 가면 다음 레벨이 나올 줄 알았으나 아래와 같은 문구가 적혀있다.
"it's in the air. look at the letters."
공기중에 있다. 글자를 보아라
위의 그림7에서 HOCKEY가 OXYGEN으로 되어 있는 걸 발견했다.
답 : OXYGEN
http://www.pythonchallenge.com/pc/def/oxygen.html로 가면 진짜 다음 레벨이 있다.
'#WarGame > Python Challenge' 카테고리의 다른 글
Python Challenge # LV.8 (BZ2) (0) | 2020.09.01 |
---|---|
Python Challenge # LV.7 (픽셀 문자열) (0) | 2020.08.27 |
Python Challenge # LV.5 (pickle) (0) | 2020.08.20 |
Python Challenge # LV.4 (0) | 2020.08.18 |
Python Challenge # LV.3 (0) | 2020.08.17 |