Page 1 of 1

Python programming?

Posted: Thu Apr 29, 2010 10:37 pm
by OvO
hi peeps...
I'm just learning to program with python at the moment.
and i was wondering if any of you guys have an idea for me for any program, doesn't matter what. just something i can tinker with for a while and is fairly easy mode would be awesome! :]

PS. I do know the absolute basics (like "while" statement and "print" and "input" and such alike.). just a hint would be great! :]

Posted: Thu Apr 29, 2010 10:59 pm
by CodeX
I'd suggest a Runaway Robot solver, it can be completed with python but can take a few minutes on the later levels and you'll probably have to change your approach to get there. If you do try this you can use urlopen from urllib (from urllib import urlopen), it's quite an interesting but simple challenge and I'm sure you'll be pleased when you manage to get to 513.

Posted: Fri Apr 30, 2010 11:12 am
by OvO
Wow thanks :]
I'm going to try that for a while
it goes like

Code: Select all

import urllib

somestring = urllib.urlopen('http://www.website.com').read()
right?

Posted: Fri Apr 30, 2010 1:19 pm
by CodeX
yup, don't forget to play with the sting formatting which can be good for the uri with something like

Code: Select all

from urllib import urlopen, urlencode
from re import match

uri = "http://www.hacker.org/runaway/index.php?name=%s&%s";
name = raw_input("Enter your username:\n");
password = raw_input("Enter your password or SPW:\n")

param2 = ""
if match("[0-9a-z]{32}",password): # The SPW is 32 lowercase hex digits
   param2 = "spw=%s"%(password)
else:
   param2 = "password=%s"%(urlencode(password))

uri = uri%(urlencode(name),param2)
response = urlopen(uri).read()

Posted: Sat May 01, 2010 12:10 am
by OvO
will do, thanks :]