Hacker News new | ask | show | jobs
by michaeldwp 4896 days ago
I remember a fun program from school. Pretty much, it was a maze solver.

Say you have a maze, and a mouse. The mouse, denoted by an uppercase 'M' character, starts out somewhere in the maze. The mouse has to find his way through the maze, to the end.

To add a bit of spice, say there's a piece of cheese at the end of the maze, denoted by the letter 'C'.

A maze would be stored in a file on disk, called something like "maze.dat." The file would be a normal text file, with a maze drawn out in simple characters.

Here's an example: http://pastie.org/5721807

(You can create a more simple / complex maze if you'd like, or maybe find one online.)

So, you've gotta figure out an algorithm that the mouse can use to find its way out.

Tip: be sure to handle the case where the mouse can't find a way out (yet) .. i.e. the infinite loop case.

I hope this helps. Have fun!

Edit: switched to pastie.org link since hn didn't format the maze properly.

1 comments

Thanks!
No problem. :)

I remember having some fun with this one. I think the prof gave us a pretty simple maze, and a fairly complex one to test with. You may want to try the same, and start by solving the simple maze.

Other than that, the advice to try and solve a real-life problem is good.

Since you're currently working in the console, it may be a bit tougher to find some problems to solve. But here's a few ideas:

1) Write a program that can download a given webpage

2) Expand #1 by writing a library that allows you to parse the different HTML nodes on the page, searching for things like "a div with an id of 'content'"

3) Write a console based file uploader. I.e. so you can have a file in the root of a directory that you're working on, say "uploader.dat", which has the ftp (or ssh/S3?) server and username, and the files to upload / exclude. When you run your app, it will check that file, prompt you for a password, connect, and upload the specified files to the server. You can have settings in the file for whether to overwrite files or not, or prompt the user to decide whether to overwrite a file. You can add a bit of smarts in by checking the "last modified" date on each file, and compare it to a stored setting of when you last uploaded files (or each individual file). Perhaps display the files that were uploaded / modified after the upload is complete.

Anyway, just some thoughts. If you can find an app / problem that you'd be truly passionate about building / solving, I'd say go with that one.

I hope this helps.