Posted by bsandersen
on July 13, 2005 at 2:55 PM PDT
Changes to Scott's home town newspaper send him returning to his roots: the one-evening-hack. Sudoku, a number puzzle, is solved by a quick-and-dirty Java program.
The Boston Globe gets delivered to my door every morning. If I do take a look at it before heading to work in the morning, I'll turn to the pages that give me the perspective I need in today's hard-hitting world: the funny pages. On this page are the things I cherish most before my daily dose of oatmeal: Dilbert , the chess puzzle, For Better or Worse , Foxtrot , and the rest of the gang.
I was met Monday with a shock to the system, though. The Globe reorganized the paper collecting all the "lighter" stuff into a section called Sidekick which now includes the comics, TV and movie listings, and the daily puzzles. A new addition thrown into the mix is sudoku , a numerical puzzle that caught my eye immediately. Sudoku is a 9x9 grid with 9 3x3 grids marked within. This grid is sparsely populated with numbers. The puzzle is solved when you fill the grid with digits 1-9 such that each row, each column, and each 3x3 sub-grid has the digits 1 through 9 appearing once-and-only-once.
Last night, during the All Star Game , I sat with my feet up in the recliner and worked one of the puzzles. Interesting! That was fun. I then had a thought: how hard would it be to write a hack to solve this?
In the very early days of the PC, there used to be a bunch of small BASIC programs that would make the rounds doing this or that. BASIC was the lingua franca of the day because it was buried into the ROMs of lots of machines of that time. And, though everybody's BASIC was a bit different, it was pretty easy to port a clever program from one version to another.
Today, we shouldn't have that porting problem: Java is Java is Java no matter where you run it. Remember the "write once, run anywhere" mantra? So, why not do the hack in Java? I did. You can find it here .
There is something very restful about doing the one-evening-hack. First, you do it only for yourself. Sure, you might share it (as I'm doing here), but that isn't the reason for doing it. You do it for the enjoyment of doing it! There are some implicit rules for the one-evening-hack:
- You must do it for yourself, not for someone else. Some of my most enjoyable hacks were done for me, by me, and were never shown to another soul.
- You must stop when you stop having fun. The pleasure is in the doing--and when it stops being pleasurable, you should stop doing.
- You don't plan on revisiting the hack. Part of the allure is you know that you won't be responsible for what you code, even to yourself! You won't go to bed thinking, "I've got to fix that file reader in the morning." Nope. When you put it down, your done.
- The hack doesn't have to be useful. Perhaps it's better if it isn't!
- You should concentrate on the stuff that makes you happy. In this case, I fooled just a bit with the comments and the code's appearance but didn't even try to give it a GUI. It was for me and I was completely comfortable with entering the puzzles into a file with vi.
- You should try something new while you do it. In my case, I gave Eclipse 3.1 a workout. The hack gave me purpose but the lessons I learned about the new feel and features of the latest Eclipse release will be more lasting than my little hack.
I've posted the little hack. Try one of those puzzles if you get a chance. And, if somebody wants to do a nicer solver for these puzzles, of course I'm interested. In the mean time, if your soul feels empty, try the one-evening-hack. And may it bring you the joy my little hack gave me!