June 2nd, 2011 21 (card game)

My housemate taught me a [drinking] card game.  I’ve been playing a lot (luckily you can play it without the drinking part!).

The Game

Someone deals 4 cards face up – you have to add, subtract, multiply & divide the values of every card to produce 21. Aces are 1 and all ‘face cards’ count as 10.  It’s kind of like the numbers section of countdown.

As soon as someone finds a solution, they hit their hand down on the table (If you are drinking – the last person to get it drinks, or if someone has their bluff called).  If no-one can work it out – then you deal the next 4 cards out.

So,  for example – if the following cards were dealt:

Ace(1), Three(3), Four(4), Jack(10)

Then the winner might work out that:

21 = (10 – 3) * (4 – 1)

It’s really satisfying to play, you get quite fast at recognising patterns (or really drunk).

Working it out

So,  this game can get a bit frustrating when you aren’t sure if a set of cards is ‘solvable’ or not.  This weekend, Chris and I were talking about this a lot – I ended up scribbling some code on the back of a plane ticket (we were supposed to be absorbing culture in Barcelona, but instead ended up arguing about maths).

This lets you find if a set of cards can be combined to 21.  It’s a bit of a brute force approach – though the problem space is so small that it doesn’t really matter.  I’ve also kind of thrown this together (only checked it on Firefox & Chrome).

We’re going to try and use this to see if there are any simple heuristics to playing (ie. totally ruining it).

  • -