royvanrijn: "This account isn't authorised" and "You are unknown in this system"... great, synchronization and can't logon :-(

Quine – McCluskey

December 4th, 2009

About a week ago I had a discussion with a fellow programmer about some boolean logic. We had three parameters, something like:

  1. personHasInsurence (A)
  2. personNeedsInsurence (B)
  3. personIsKnownAtThisAgency (C)

We also had two particulair cases for an insurance page:

Case 1:
Person has insurence and isn’t yet known at this agency

Case 2:
Person doesn’t have insurence, needs insurence and is known at this agency

Case 3:
Person doesn’t have insurence, doesn’t need insurence and is known at this agency

So the view-logic was a bit complex:

if( (A && !C) || (!A && B && C) || (!A && !B && C ) ) {
    showPage();
}

Then I remebered something I learned at school some time ago. So called karnaugh maps. I’ve completely forgotten how to use them, but I knew it was possible to calculate the shortest form to comply to the logic rules. When looking further I found the so called “Quine McCluskey“-algorithm, and I decided to implement it (just to learn how it works).

Quine – McCluskey algorithm

First of, lets go through a couple of terms.

Continue reading »

Corewars – Brainf*ck

December 2nd, 2009

I’ve implemented a Brainfuck interpreter!

Yes, you heard it right, Brainfuck (BF).
BF is an esoteric programming language. More information on BF can be found here.

The language itself is pretty simple, and most of it was implemented rather quickly in Redcode. The only big problem was navigating back to the correct closing brackets in a loop. This is now solved by counting the amount of open/close brackets in between.

So here is the code:

Continue reading »