Sudoku Solver/Generator Source-Code


Here’s some straight-to-the-point source-code for solving and generating Sudoku boards.
It’s targeted at embedded systems, so stuff will run fast and memory consumption is rather low.

I’m putting it here mainly so that people can find it through google and have some of the Sudoku programming-problems solved. The source-code is heavily commented, so hopefully it’ll do some good.

Here we go:

common.h, os.h (just common stuff)
Board.h, Board.cpp (The core stuff)
SudokuZen.cpp (Usage example)

A package that may compile: SudokuZen.zip
The picture was drawn by my brother, for a game we never released.

Hacking the EasyHotel TV (incomplete)

I found myself at the London EasyHotel. Don’t book a room there if you’re claustrophobic :-)

The room has a nice Phillips FlatTV, but it has no visible buttons and no remote… If you want a remote it’s for 24 hours, yeah you read it right.

Unwilling to shell out that money for 5 consecutive days and letting out the real me, I decided to give it a shot.
We went over to one of these everything for 1£ shops and got ourselves a universal remote-control.

We got back to the room, gulag-cell is a better name, and tried out the remote. Use codes 027 or 003 to match the ‘IR Codes’ of EasyHotel’s Phillipsps FlatTV. This enabled us to turn on the TV and get to a nice channel that shows us the channel-selection and plays music-radio at the background.

The TV has many inputs, Coaxial, AV, RGB, S-Video. We managed to jump between all of them but didn’t manage to move between channels :-(
It seems like Coax and AV broadcast the same channel-selection, the latter only doing it in Stereo instead of Mono.

We tried all of the ‘IR Code Sets’ that match Phillips but not one of them managed to switch the channels.

To me it still looks like the correct ‘IR Code’ will solve the problem, but I’m ready to hear from other people, as there’s no other place on the web I could find information on hacking this specific TV-Set.

It’s still nice though, the 1£ remote is worth having some background music as that’s about the only dynamic thing about the room (no window, ouch).

Comments ?

PyIE: Easy Screen-Scraping with Python and IE

I always like it when information I’m interested in just flows over to me.


The first thing I did about this was start sending myself daily reports about my investment-account. I wrote a script that logged into the bank, fetched the info I wanted, and spat it out. A simple batch file was all it took to pipe this into another tool that simply sms’s the data over to me. This essentialy makes any worthy piece of data instantly deliverable to me wherever I am.

This just sound like you’re typical Matrix-hackerish style paragraph, but if you’re a moderate computer programmer, the next few paragraphs will clear it all up ;-)
If you’re not a programmer, The Matrix stuff is comming in masses.


Screen scraping is the act of capturing data from a system or program by capturing and interpreting the contents of some display that is not actually intended for data transport or inspection by programs

source: wikipedia


The first thing you’ll want when you’re scraping for data is an easy way to control and fetch data from, let’s say, a browser.

I picked IE. I know it sucks but it’s easy to automate.

Anyways, any web-page is easily accesible through what’s called the DOM. To find out where in the DOM lyes the piece of data you’re after, use the priceless DOM-Inspector, a click here and a click there and you suddenly know that you’re daily loss/gain is neatly located at :
document.frames.middle.document.frames.IFrames.document.
getElementById(“QTable2″).childNodes.item(0).childNodes.
item(0).childNodes.item(0).childNodes.item(0).childNodes.
item(2).innertext
I would have never guessed this myself.

Now how do we automate all this process ? I mean we need to load up the page, fill in the form with our username/password, click ‘login’, click a few more buttons, fetch data, etc…
This is where Python + win32com + PyIE come to the rescue.

Python is fun and easy for scripting. PyIE is a small component I’ve written that simply loads up an invisible IE page (or visible if you want to debug stuff), and just does whatever you tell it to do. It handles lots of annoying issues like ‘click here, now wait for the stuff to come up’. Most components I tried to use required you to manually timeout the requests and handle things yourself, which is tiresome.

PyIE solves almost all of the tedious work of timing, error-handling and stuff like that.

PyIE provides a single method that safely fetches data or fills forms with your data, and is thus called safely.

Download: PyIE.py
Examples: send_sms.py (send an SMS in IL-Orange), stat_counter.py (fetch info from your account at statcounter).

The two examples are most likely outdated (that’s the bad thing about screen-scraping), but use them to learn how to use PyIE.

Did I mention Python is beautiful ?

iPod Shuffle without iTunes

ipod shuffle The great guys at BeInSync got me an iPod-Shuffle yesterday.

The moment I started skimming through the manual I figured this a’int gonna be an easy match up. Apple seems to really want you to install iTunes, maybe it’s an attitude problem. I personaly dislike having to install software that I don’t need.

Why can we simply not use iTunes ? Because Apple intermixed iTunes and the Shuffle just to damn nicely together :-) (Read more here)

Martin Fiedler wrote a great tool that takes iTunes out of the equation. It path.os.walk()’s your iPod and builds a file with all the MP3s you’ve got there, so that the iPod knows what to play. You need to run it whenever you finish adding/removing mp3′s from your iPod, but heck it’s better than doing it all through iTunes.

There were two things I missed in Martin’s program:

  1. It has to sit in the root of the iPod’s directory-structure.
    Added a command-line argument ‘-r’ or ‘–root’. If you choose to put the program in ‘/programs/builder_db’ it will simply change to ‘/’ before starting to run, which now means you can put it wherever you want :-)
  2. There wasn’t an EXE version (it’s written in Python, what if I got to a friend and he doesn’t have Python installed ?)
    This was simple, we just use py2exe to make ourselves an executable version.

This now allows me to have the following directory structure on my Shuffle:

  • \Music – this is where I put all my music/podcasted-stuff.
  • \rebuild_db – the executable version of rebuild_db together with it’s DLLs.
  • rebuild_db.bat – this one sits in the root of the iPod and simply contains: rebuild_db\rebuild_db.exe –root –nolog

Here’s the executable program: rebuild_db.zip (1.1MB)
Here’s the modified Source: rebuild_db-0.6-pre2.zip