Posted: Sat Feb 13, 2010 5:47 pm
if looking at it as it is doesn't work anymore, try looking for underlying patterns which you can use to solve it
gfoot wrote:It's pretty easy in most modern languages. e.g. in Python 2:
That should give you an array of lines.Code: Select all
import urllib pagedata = urllib.urlopen("http://www.hacker.org").read().splitlines()
In Python 3 it's been moved around a bit - I think you need:
But I don't have Python 3 installed, so I can't check it for sure.Code: Select all
import urllib.request pagedata = urllib.request.urlopen("http://www.hacker.org").read().splitlines()
Once you've got the data you'll have to parse it to extract useful things like the board size and contents, then write the fun bit of your code that figures out a good route.
It's actually probably better to do the fun bit first, though, so you can make test boards locally without having to wait for web requests from time to time. All my hacker.org solvers support this, and cache any downloads locally as well so I can replay them later - it's good to have some smaller boards available when you're profiling an algorithm and want faster results.
anddata = urllib.urlopen("http://www.hacker.org").read().splitlines()
AttributeError: 'module' object has no attribute 'urlopen'
Python Version 2.6.5import urllib.request
ImportError: No module named request
Code: Select all
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;
namespace crossflipsolver
{
class Program
{
static string username="yourusername"
static string password="yourpassword"
static string baseurl = "http://www.hacker.org/cross/?name="+username+"& password="+password
static void Main(string[] args)
{
HttpWebRequest myrequest = (HttpWebRequest)WebRequest.Create(baseurl);
myrequest.Method = "GET";
WebResponse myresponse = myrequest.GetResponse();
StreamReader sr = new StreamReader(myresponse.GetResponseStream(), System.Text.Encoding.UTF8);
string result = sr.ReadToEnd();
puzzle = parseweb(result);
}
static string parseweb(string input) {
//put your parsing code here,
}
}
}
MerickOWA wrote:Learn how to write a program? pick your favorite language java,c,c++,c#,ruby,python,lisp and learn how to download webpages in that language, and parse out of the html the maze data.
After that, you have to figure out how you want to solve the problem. The simplest method (but the longest) is to just search through all possible answers until you find an answer that solves the problem. (try each instruction length, and each combination of down(s) and right(s) until your robot makes it to the edge).
However, I don't think you'll get to level 513 with that method. You can either work on ways of speeding up your searching techniques and/or simplifying the problem so there are fewer possibilities to search.
thanks for u help and how i can get these programming languages?Wooshee wrote:MerickOWA wrote:Learn how to write a program? pick your favorite language java,c,c++,c#,ruby,python,lisp and learn how to download webpages in that language, and parse out of the html the maze data.
After that, you have to figure out how you want to solve the problem. The simplest method (but the longest) is to just search through all possible answers until you find an answer that solves the problem. (try each instruction length, and each combination of down(s) and right(s) until your robot makes it to the edge).
However, I don't think you'll get to level 513 with that method. You can either work on ways of speeding up your searching techniques and/or simplifying the problem so there are fewer possibilities to search.
Hi what book should i Begin with in order i can become a hacker please?
Perhaps, i'm unfriendly.. Butthanks for u help and how i can get these programming languages?