CodeJam, a lesson in Haskell IO

As you may know yesterday took place the qualification round for the Google Code Jam contest. While it’s start time was around 2AM in my timezone I felt pretty excited to participate, given that my objective was to use Haskell and get better in it.

From the problems that where exposed, Goro sort was the single one which I had managed to complete; not in the 24h span, but in my spare time, I had a pretty busy schedule this Saturday.

So how did it go?

Well, once the problem clicked the solution was writable in a couple of minutes (like of what I assume was the case with most of the problems); but never having played with IO before in Haskell (of course I’m still a beginner) I copy pasted the input – output routine from Real World Haskell.

My solution looked marvelous:

Until today when I’ve seen rst76′s solution:

And found about interact. Now marvelous doesn’t quite fit as a description for my solution.

note to self: y u no read complete page?

Filed under Challenge, Code