Differences

This shows you the differences between two versions of the page.

programiranje:python_challenge:nivo_6 [2009/11/23 09:06] (current)
delboy created
Line 1: Line 1:
 +===== Python Challenge - Nivo 6 =====
 +U [[http://www.pythonchallenge.com/pc/def/channel.html|ovom nivou]] nema mnogo uputstava. Jedino što sam našao (i što je bilo sasvim dovoljno) je reč zip na samom početnu source-a strane. Kada se //channel.html// zameni sa //channel.zip// skida se file. Kada se raspakuje dobije se gomila tekstualnih fajlova čiji je sadržaj isti kao sadržaj iz [[nivo_4|četvrtog nivoa]], a imena file-ova su brojevi, tako da se isti algoritam nameće kao rešenje. Kada se dođe do kraja tekst kaže da treba skupiti komentare. To se radi direktno iz zip file-a. A kad se već čita direktno iz zip fajla možemo i sadržaj pokupiti, tako da uopšte nema potrebe raspakivati fajl.
 +<code python>
 +#!/usr/bin/env python
 +
 +import re, zipfile
 +
 +file = 'channel.zip'
 +z = zipfile.ZipFile(file)
 +comments = [];
 +
 +def iterate(start):
 +    nothing = start
 +    while True:
 +        comments.append(z.NameToInfo[nothing + ".txt"].comment)
 +        txt = z.read(nothing + ".txt")
 +        try:
 +            if re.search("Devide", txt):
 +                nothing = str(int(nothing) / 2)
 +            else:
 +                nothing = re.findall("(\d{1,5}$)", txt)[0]
 +        except :
 +            break
 +
 +
 +nothing = "90052"
 +iterate(nothing)
 +
 +for i in comments: print i,
 +</code>
 +
 +Ovaj kod daje [[http://en.wikipedia.org/wiki/ASCII_art|ASCII art]] na kome piše **hockey**. Kada se ta reč unese dobije se strana sa tekstom "it's in the air. look at the letters. ". Kada se pogleda svako slovo u reči hockey je napisano od smao jednog slova. Kada se ta slova iskoriste dobije se pravo rešenje.
 +
 +**Rešenje**: http://www.pythonchallenge.com/pc/def/oxygen.html
 
programiranje/python_challenge/nivo_6.txt · Last modified: 2009/11/23 09:06 by delboy
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki