# Gaussian elimination step by step

It’s easy to make small stupid mistakes when you do matrix calculations manually. I put together a simple tool in javascript that performs Gaussian elimination step by step.

http://g.bonds.nu/gauss/

Enjoy 🙂

# Contra Benedictum

Against Benedict.

Saint Benedict wrote his Regula Monachorum, his Monastery Rules in the middle of the sixth century AD. He starts chapter 48 with the famous sentence:

Otiositas inimica est animae – Idleness is the enemy of the soul.

I don’t agree with him. I think idleness is more of a blessing than a curse. Today many people never experiences idleness because every second of every day and night they are connected to the never ending flux of Facebook, Instagram,  Snapchat and Twitter.

For me idleness is not the enemy of the soul. Idleness is a prerequisite for being creative.

If I could rephrase Saint Benedict’s words I would write something like:

Otiositas fontem creativitas est – Idleness is the fountain of creativity

# Two-Dice Pig – Coding Battle

Two-Dice Pig is a classic game where you throw a pair of dice over and over and sum up the points you get. When you reach one hundred, you win. Easy? Well, there is one little problem. If one of your dice show a one, all your points are lost and the turn goes over to your opponent who faces the same challenge. There is a way to keep your accumulated points though and that is if you declare that enough is enough and hand over the dice to your opponent. In that case you get to keep your points. They are transfered to your ”bank”. The points in your bank are safe there unless you happen to roll two ones (snake eyes).

Though the game is very simple (or rather because the game is very simple), soon you start wondering about the optimal strategy. For how long will you risk keeping on rolling your dice? Is there a recommended limit? Or is there a recommended number of times you should try to roll the dice before you declare that your satisfied?

I created a web app in Javascript where you can compete against an opponent in Two-Dice pig. But you don’t play directly. You compete with your strategy. You design your strategy and then you challenge the strategy of your opponent. The standard option is to play one thousand games of Pig and in just a wink of an eye you can see which strategy is the best.

Your gaming strategy is designed by coding a Javascript condition for when to continue rolling your dice.

The variables you can utilize are the following:

a: Points accumulated during the current round
b: Index number keeping track of how many rolls you’ve made during the current round. If its the first throw b = 1
c: Points In The Bank
d: Opponent Points In The Bank
e: PlayerIndex. If you’re the first player starting out: e = 1. Otherwise: e = 2

In this implementation of the game the second player always has a last chance to try to catch up with the first player even though one hundred is already reached. If you play one thousand games you will be player number one in exactly 500 of the games.

Example: Here’s a legal strategy:

b<4

It means that as long as the number of throws are lower than four you will continue to roll the dice. In other words; when you have rolled the dice four times you declare that it’s your opponents turn.

Here’s another legal strategy:

a<12

This means that as long as you haven’t reached 12 points during the current round you will continue to roll the dice.

And here’s yet another one:

a<12 && a+c<100

This means that there are TWO conditions that need to be meet with for your rolling to continue.

The accumulated point during the current round must be lower than 12 AND the sum of the accumulated points and your points in your bank must be lower than 100.

The simplest valid strategy would just be

1 == 0

or just

false

That means that you never continue to roll. You roll the dice only once, each time it’s your turn, but that’s it.

There are two strategies that can be edited on screen. One for the ”Blue program” and one for the ”Red program”. They can compete against each other. There’s also a third pre-programmed strategy belonging to the so called ”Champ program”. That a strategy is one that I’ve coded myself that I’m pretty happy with. The ”Champ program” is, I imagine, pretty hard to beat so, as an ultimate test for your own strategy you can also challenge the champ program. Can you beat the Champ?

Note: The idea of designing the perfect strategy for this game has attracted interest from mathematicians and computer scientists. Here’s a link to a pdf – Optimal Play of the Dice Game Pig – published by the computer science faculty at the Gettysburg College. The list of academic references in the end of that publication is great if you’re interested in delving deeper into the subject.

# Pastafarian Colander

Someone needs to start manufacturing stylish and comfortable pasta strainers that bring out your good looks. But seriously. How hard can it be to design a pasta strainer with a shape that fits a human head? The pastafarian community needs better lobbyists or entrepreneurs.

# Steganography

Steganographic storage of encrypted files in images.

What I find truly fascinating is that there is no way to tell if an image contains steganographically hidden encrypted data. Even if you know every line of the source code of the program that you suspect may have been used to hide the data, you still have nothing to help you prove anything.
If the least significant bits in the RGB-values contains encrypted data they should appear to be random. But the least significant bits in an ordinary image on the other hand, could be expected to be less random and show a bit more regional uniformity.

But randomness in the least significant bits does not constitute proof that there are encrypted data hidden. The randomness of the RGB-values could originate from natural minute color shade variations in the surface of the physical object being photographed or be the result of an image editor filter.

I’ve been working on an encryption program in C# for a couple of days. It encrypts files and hides the encrypted data steganographically inside images.

The portrait above actually does contain data that can be extracted and be visually interpreted in an unexpected way. Hidden in the above images is another image. The image you see below:

I think that maybe it’s wrong to say that the initial image contains hidden data. There are no hidden data. All data in the initial image is visually represented on the screen. The question is how you interpret the data.

To make things more interesting I can reveal that the above bluish image also contains something that you might not expect.

Encoded in the pixels is a text file with the 81 verses of the ancient Tao Te Ching by Lao Tzu.

1
The Tao that can be trodden is not the enduring and
unchanging Tao. The name that can be named is not the enduring and
unchanging name.

(Conceived of as) having no name, it is the Originator of heaven
and earth; (conceived of as) having a name, it is the Mother of all
things.

Always without desire we must be found,
If its deep mystery we would sound;
But if desire always within us be,
Its outer fringe is all that we shall see.

Under these two aspects, it is really the same; but as development
takes place, it receives the different names. Together we call them
the Mystery. Where the Mystery is the deepest is the gate of all that
is subtle and wonderful.

Above you see only the first verse. The bluish image contains all 81 verses!

# Four Seasons challenge

It’s fun to see how fast you can learn to discern between all twelve movements in Antonio Vivaldi’s Four Seasons. I made a web app in Javascript to make it easy to explore the music and challenge yourself with a graded test. To get an A you need to listen and figure out the correct season and movement for 13 out of 16 music excerpts. Click on the picture above to try it out.

# Efficient recursive maze algorithm

I made a recursive bisecting maze algorithm in just eight lines of code. (click on above image to see it in action)

The efficiency of the algorithm comes at the cost of a fairly low entropy. It means that the randomness of the maze is limited. A high entropy algorithm could ideally produce a maze where you had to traverse every room in the labyrinth in order to move from the room in the bottom left corner to the room to it’s immediate right. This could never be the case with the above listed bisecting algorithm where internal access between rooms within the same bisection is always guarantied.