in reply to What do you write when learning a new language?
My favorite "first program" to write in a language is the Knight's Tour. My reasons are basically that it's easy to implement and since I don't often learn more than one language a year, it also helps me keep track of how much faster computers are getting. (I make the board size a parameter, and have it keep solving larger and larger boards until I'm bored watching it.)
Once I've written it, I look around and see if I can make it more idiomatic for the language. (Why write in the C subset of a language? If that's what you want, just use C.) Some languages offer the opportunity to use a different data structure for the board or other implementation strategies. After I get it running nicely, I try to see if I can code up new heuristics to chop off subtrees. It's often a fun way to spend a day when you need to relax.
I don't know exactly how many versions I've written, but it's likely between 25 and 35. (Not counting the hacking sessions of optimizing and idiomizing, etc. If I were to count those, it could possibly be well over 500.)
I just realized something ... I've never done it in perl. If I weren't at work right now, I'd do that. As it stands, I think I'll do it this evening and post it tonight or tomorrow.
...roboticus
|
---|