Page 1 of 1

problem in automating the puzzle

Posted: Mon Jun 06, 2011 5:05 pm
by bodjo
hi guys i have already create a python solver for this puzzle but the only problem is i don't know how to get values from variables in the site
i think i need some help :roll:

Posted: Mon Jun 06, 2011 5:18 pm
by uws8505
Simply pick a simple level (possibly level 0) and take a look into its source code.
You can find everything about the puzzle shown on the page in the source code.
Also, don't try to figure out the line number where the problem values, but rather a keyword where the problem values are in the same line. This way, the program is guaranteed to obtain the problem values, and the code is also quite simple in Python.

Personally I did beat this with C++ when I didn't know Python, but copy-pasting the problem every time to notepad was really a pain...

Posted: Mon Jun 06, 2011 5:24 pm
by bodjo
yes but i want from the solver to automaticly do that

Posted: Mon Jun 06, 2011 5:49 pm
by laz0r
You can use various string manipulation functions to spot the variables automatically. Import the page, cut out the bits you don't need, parse the bits that are left.

Posted: Mon Jun 06, 2011 5:51 pm
by bodjo
good idea :lol:
thank you

Posted: Wed Jun 08, 2011 11:42 am
by virus171
Hi guys. With regards to automation, I have been able to extract all of the useful information from the source code, but when it submits the answer, I am always told that my answer sucked. I check my solution with the string representing the layout of the map obtained from the source code and find no problem.

Just wondering what I am doing wrong and how to fix it

Posted: Wed Jun 08, 2011 9:58 pm
by MrTerry
well could be anything.....
since it tolds u that ur solution sucked means ur locked in.... so there must be something within the solution itself....could u show an example url u would use ?

Posted: Fri Jun 10, 2011 12:42 am
by megabreit
You need to save the session cookie and use it when posting the result!
Otherwise you get a different level each time... and the solution for the old level sux all time :-)

Posted: Fri Jun 10, 2011 5:13 am
by virus171
Thanks for the replies
Would you be able to tell me how i would do that in python? I don't have very much (any) experience in doing this sort of thing. I did a search, but I'm not exactly sure what's needed.

Posted: Fri Jun 10, 2011 5:48 pm
by megabreit
I can tell you how this works in perl:

Code: Select all

my $request = HTTP::Request->new(GET => "http://www.hacker.org/runaway/index.php?name=$user&password=$password");
$ua=LWP::UserAgent->new;
$response = $ua->request($request);
$session=$response->header("Set-Cookie");

[...] and later on:
my $header=HTTP::Headers->new;
$header->header('Set-Cookie' => $session);
my $request = HTTP::Request->new(GET => "http://www.hacker.org/runaway/index.php?name=$user&password=$password&path=$path",$header);
It's probably very similar in python... check the online doc :-)

Posted: Sat Jun 11, 2011 2:39 am
by virus171
Thanks for your help. :) I'll see if I can get it working with this

EDIT: Thanks to your info, got it working! :D Now lets see how far i get with this basic solver