Skyline puzzle

One of my colleagues brought the following puzzle to work:

Skyline puzzle

The puzzle is called Skyline and it’s a packing puzzle. The objective is to place the metal rod in one of the holes in the base and place the nine wooden pieces around it. It was designed by Jean Claude Constantin. When solved, the puzzle looks something like this:

Skyline solution

Sometimes with these kinds of puzzles it’s quicker to write a program that finds a solution than trying to solve it by hand. Check out this github repository for a Prolog program that finds solutions for a given rod location.

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

You can press ; to find alternative solutions. The pos(X,Y) part refers to the location of the metal rod.

MLP in C++11

In this post I present my Christmas gift to the world: A multilayer perceptron written in C++11.

I mainly wrote this to get some practice with some of the new C++11 features such as variadic templates and lambda functions. It uses template metaprogramming to construct (but not train) the neural network at compile time. You can download the code from its github repository. It’s lacking proper documentation, but I’ve included two examples that should get you started: the xor problem and Fisher’s Iris data set.

Happy Holidays.

Statisticians are evil

I’ve made it my life’s goal to replace all statisticians with cute little robot bunnies. Watch the following video for a demo of my first prototype.

I developed a server in Prolog for the Nabaztag:tag bunny and hooked it up with a dialogue system I created during my masters. It uses an unofficial Google API for speech recognition and generation. It’s quite slow sometimes because of the poor Wi-Fi connection, the inefficient polling of the Nabaztag and the speech recognition. I have some ideas though for improving its speed. Read on for a transcript of the dialogue with comments.

Continue reading

VBA IBAN Validator

From February 2014 onwards, IBAN will be the new European standard for bank account numbers. This standardization is part of the SEPA initiative to improve the efficiency of cross-border euro payments. I wrote an IBAN validator in VBA for an MS Access database I’m maintaining, but you can also use it in Excel or any other application that supports VBA.

The function ValidateIban takes an IBAN bank account number and returns True if the number is valid and False otherwise. It checks if the length is correct as per country and if, after rearranging and converting the IBAN code to an integer, the remainder of the modulo 97 operation equals 1. See wikipedia for a description of how to validate an IBAN number.

Sinterklaas kapoentje

Het is weer bijna Sinterklaasavond, dus tijd voor cadeaus, surprises en gedichten!

Een originele manier om je gedicht te presenteren is door middel van een Word document waarbij het gedicht woord voor woord verschijnt zodra je het document opent. Dit is vrij simpel te bewerkstelligen. Je schrijft eerst de tekst van het gedicht in een nieuw en leeg Word document. Vervolgens selecteer je alle tekst en maak je de kleur van de tekst wit zodat je niet meer kunt zien dat er wat staat. Door middel van de volgende VBA macro code maak je dan woord voor woord het gedicht zichtbaar:

Verder moet je dan nog wat code toevoegen om bovenstaande subroutine aan te roepen zodra het document geopend wordt.

Zie hier voor een voorbeeld. Denk er wel om dat je het uitvoeren van macro’s moet toestaan.

Self-organizing bookcase

This is what my bookcase looked like before:

Books unsorted

And this is what it looks like now:

Books sorted

Much better!

So how does a geek organize his books? He uses a technique called self-organizing maps (SOM).

I basically took a high resolution photo of my bookcase (the first picture shown) and then cut out all the book spines and saved them as separate images. After doing that I had 347 little images. I used the ImageMagick command-line tool to resize all these images to a 1×1 picture. I figured that the single pixel in these images would more or less approximate the average spine color. The RGB values of these pixels were then used to train a 1 dimensional SOM. After training, the best-matching unit on the SOM for each bookspine was determined telling me how I should reorder my books.

And yes, I realize that there are easier ways to sort books by color 😉