Differences

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

programiranje:python_challenge:nivo_4 [2009/11/23 09:06] (current)
delboy created
Line 1: Line 1:
 +===== Python Challenge - Nivo 4 =====
 +U [[http://www.pythonchallenge.com/pc/def/linkedlist.php|ovom nivou]] je slika link. Kad se klikne na sliku dobije se text "and the next nothing is 92512", a u linku se pojavljuje "?nothing=12345" što znači da bi trebali da zamenimo broj za nothing. U source-u piše da modul //urllib// može pomoći i da ne treba probavati sve //nothing//-e.
 +Na osnovu probavanja primetio sam da text nije uvek isti, pa je na osnovu toga i program promenjen.
 +
 +<code python>
 +#!/usr/bin/env python
 +
 +import urllib, re
 +
 +
 +def iterate(prefix, start):
 +    nothing = start
 +    while True:
 +        a =  urllib.urlopen(prefix + nothing).read()
 +        print a
 +        try:
 +            if re.search("Divide", a):
 +                nothing = str(int(nothing) / 2)
 +            else:
 +                nothing = re.findall("(\d{1,5}$)", a)[0]
 +        except:
 +            print "Verovatno je resenje u prethodnom redu..."
 +            break
 +
 +base = "http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing="
 +nothing = "12345"
 +iterate(base, nothing)
 +</code>
 +
 +**Napomena**: U zavisnosti od internet konekcije, program će raditi od minuta do desetak minuta.
 +
 +**Rešenje**: http://www.pythonchallenge.com/pc/def/peak.html
 
programiranje/python_challenge/nivo_4.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