Deduction Machine

I made a machine today that solves logical puzzles like this one:

I won’t eat my hat
If hippos don’t eat acorns, then oak trees will grow in Africa
If oak trees don’t grow in Africa then squirrels hibernate in winter
If hippos eat acorns and squirrels hibernate in winter I’ll eat my hat

Then what…?

It’s a machine that states the obvious…

Annonser

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 🙂

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.

Use Game of Life to Generate 256 bit Hash

One of the most fascinating aspects of Game of Life is that it illustrates so well how a completely deterministic process can be so unpredictable. Use a fixed starting pattern and run. Watch the result. Use the same starting pattern but change a single cell somewhere. The new result can be as different from the old as night and day.

Absolute determinism plus unpredictability are precisely the two things you look for in a hash algorithm. When you store passwords on a server you don’t store the passwords themselves but their hashes, calculated using some hash algorithm like for example MD5, SHA-256 or Whirlpool.

A user authenticating himself on the server inputs his password and the server hashes the password to see if the hash corresponds to the hash stored on the server.

For a hacker getting hold of the stored hashes, or for the system administrator, there is no way to run the hash algorithms backwards to retrieve the real passwords. The only way to break a hash is to systematically hash every possible password (out of zillions) and see if the hash matches.

I made this Javascript application to illustrate the idea of using Game of Life to generate hash values. The application is not using Conways standard B3/S23-rules but instead B23/S23-rules.

Try to hash different words or sentences differing only by a single letter adjacent in the alphabet and watch how the hash value changes. You can also try to hash some text but before you click on the ”Run 200 steps” click somewhere on the gird with the mouse pointer to change a single bit.

Game of Life with B345/S45 rules

A lot of people are familiar with British mathematician John Horton Conway’s ”Game of Life” – an algorithm to simulate cellular growth and decay, first published in Scientific American in 1970.

The concept is simple. Imagine an infinite grid of empty squares. Each of these squares can either be empty or occupied by a ”cell”. The are only two rules. One rule for empty squares (the birth rule) and one rule for squares occupied by a cell (the survival rule).

Birth: If an empty square has exactly three neighboring cells a new cell is born in that square.
Survival: An existing cell will only survive if it has either two or three neighbors.

These two rules implies a time axis along which the grid will project forward in discrete phases.

But why do we have these specific rules? Why is exactly three neighbors required to give birth to a new cell?

Conway’s classical rules are sometimes abbreviated to the code B3/S23.

The reason for these particular rules to have become so popular isn’t that strange. Anyone who has experimented with a simulation engine using these rules knows that they often create very complex and interesting situations.

But this being a fact doesn’t exclude the possibility of other rules also having the potential of creating complex and interesting scenarios.

Conway himself and others have explored a lot of other possible rules for Birth and Survival.

I played around two days ago with my own javascript-powered game of life engine where I can chose any set of rules for birth and survival. I wanted to explore an idea I had to use the game of life cellular automaton concept to create a cryptographic hashing algorithm. So, by a mere coincidence, I tried the B345/S45 rules and was fascinated by the way that an initial small colony of cells transformed during hundreds of phases only to later die out. This was almost always the fate that awaited small colonies occupying an initial eight times eight square. I tried out new random shaped colonies, one after another and very seldom a shape would pop up that wouldn’t die out but instead grow and grow and never stop growing. How come, I wondered?

I dealt with this question systematically and found out that there are only 36 symmetrical shapes out of a total of 37888 that will grow indefinitely. All the other symmetrical 8×8-shapes will eventually be either totally annihilated or get stuck in small for ever repeating loops of shapes (so called pulsars).

Here is the total set of miracle seeds – the smallest possible symmetrical shapes that I found that will grow forever. All the tens of thousands of others are destined to perish or stagnate.

I have shown that there exist no smaller symmetrical shapes, for example 7×7-shapes or 6×6-shapes, that will grow indefinitely.

Add or remove a single pixel anywhere and they will die – that’s how sensitive they are (try it out for yourself).

So these are the symmetrical ones. What about the asymmetrical ones?

I don’t know, but I guess that you can’t find an asymmetrical shape smaller that 8×8 that will grow indefinitely.

It could be tested systematically but the number of all shapes that occupy a maximum space of 8 times 8 squares are much larger than just the symmetrical ones.

Click on this link or on the picture above to go to my B345/S45 simulation engine.

Update: July 28 2015

Amazing news. After seventeen hours of automatic testing of random shaped populations eight different asymmetric 8×7 indefinite growers presented themselves!

I  also found three shapes that lasted a long time but in the end didn’t quite make it.

They lasted 539, 542 and 716 (!) rounds respectively.

Smoothest Possible Line

I lost myself in an equation last night. Didn’t get much sleep. What’s the smoothest possible line connecting four arbitrary points? Find out for yourself by dragging the points around in the javascript program I made. Click on the picture…