Python programming?

Discussion about hacker.org's server
Post Reply
OvO
Posts: 11
Joined: Fri Mar 19, 2010 10:18 pm

Python programming?

Post 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! :]
User avatar
CodeX
Posts: 350
Joined: Fri Oct 17, 2008 5:28 pm

Post 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.
OvO
Posts: 11
Joined: Fri Mar 19, 2010 10:18 pm

Post 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?
User avatar
CodeX
Posts: 350
Joined: Fri Oct 17, 2008 5:28 pm

Post 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()
OvO
Posts: 11
Joined: Fri Mar 19, 2010 10:18 pm

Post by OvO »

will do, thanks :]
Post Reply