Icosian game

The Irish mathematician William Rowan Hamilton is probably best known for discovering quaternions. He is also the inventor of the Icosian game.

The game’s objective is to find a path around a dodecahedron such that every vertex is visited once, no edge is visited multiple times, and the path ends in de same vertex it started from. Instead of using a 3d dodecahedron, the game was distributed as a pegboard with holes at the vertices of the 2d dodecahedral graph.

The game was meant to be played by two people. The first player would set up the challenge by placing the first five pegs in any five consecutive holes and then the second player would be required to place the remaining fifteen pegs consecutively in such a way that the succession would be cyclical.

One of the few remaining copies (from the collection of the puzzle museum)

In graph theory, a path that visits every vertex of a graph once is now known as a Hamiltonian path. A path that visits every vertex once and that ends in the same vertex as it started off from is called a Hamiltonian cycle. So playing this game is essentially searching for a Hamiltonian cycle in the dodecahedral graph.

The Icosian game was never a commercial success, probably because it’s too easy. I wrote some Prolog code to solve this game and explore possible solutions. Entering solve_icosian_puzzle. and pressing ; repeatedly will yield possible solutions.

Suppose you want to explore how the cycle that starts with the vertices Q, R, S, N, P could be continued, you would enter:

icosian_puzzle_edges(Adj), Tour = [q,r,s,n,p|Rest], hamiltonian_cycle(Adj,Tour), print_icosian_solution(Tour).

This game might remind you of the Travelling Salesman Problem (TSP). Finding a Hamiltonian cycle can be considered a special case of the TSP, namely, one where each pair of vertices with an edge between them has distance 1, while vertex pairs without an edge between them are separated by a distance of infinity.

Bart the bartender


Check out the video below or chat with Bart here http://m.me/bart.the.bartender. Be sure to like its Facebook page https://www.facebook.com/bart.the.bartender!


Supercharging the Nabaztag

The Nabaztag is a WiFi enabled ambient device shaped like a bunny. It has moveable ears, a speaker, several LEDs, and a button on its head. The second generation (the one I have) also has a microphone, an RFID sensor, and supports MP3 audio streams.

These Nabaztag bunnies rely on a server to function. Originally the company that produced these things provided for one but after they went bankrupt in 2009, thousands of these devices were rendered useless.

Luckily, various alternative servers were developed. These servers often make use of plugins to give the connected bunnies certain abilities. Extending your bunny with new capabilities requires some programming skills if there is no existing plugin that already does what you want.

I developed my own Nabaztag server in Prolog that you can download from this repository. Instead of making use of plugins to extend a Nabaztag’s capabilities, my server simply forwards all events to an IFTTT webhook. The server also exposes an API to do things like play audio, flash LEDs, move the ears, do TTS, etc. This API can be called from the IFTTT platform.

Continue reading

Dr. Stat

This is a demo of my chatbot called Dr. Stat.




Read on for a transcript with annotations.

Continue reading

Skyline puzzle

One of my coworkers brought the following puzzle to work:



To use this program open the file skyline.pl in your favorite Prolog interpreter (e.g. SWI-Prolog) and execute the following:


Bridge and torch puzzle



A, B -> 2
A <- 1
A,C -> 5
A <- 1
A,D -> 10



A, B -> 2
B <- 2
C,D -> 10
A <- 1
A,B -> 2

Which gives a total crossing time of exactly 17 minutes.


Einstein’s riddle



The question is: WHO OWNS THE FISH?


  • the Brit lives in the red house
  • the Swede keeps dogs as pets
  • the Dane drinks tea
  • the green house owner drinks coffee
  • the person who smokes Pall Mall rears birds
  • the owner of the yellow house smokes Dunhill
  • the Norwegian lives in the first house
  • the owner who smokes Bluemaster drinks beer
  • the German smokes prince
  • the Norwegian lives next to the blue house
  • the man who smokes blends has a neighbor who drinks water


Sudoku solver


Here is how to use my program:

Then you can enter the known numbers one by one.

When complete, the program determines and prints the solution.





The prolog environment I used here is SWI-Prolog.

A brainf*ck interpreter in Prolog

The language brainfuck is extremely minimalistic, consists of only eight commands and is Turing complete. Writing an interpreter for it in Prolog is a breeze.

You can download my interpreter here. I’ve included some brainfuck programs I found at ‘The brainfuck archive’.

To start a brainfuck program from Prolog do the following:

It’s not the fastest interpreter around, but it’s a nice example of how to build one in Prolog.