Time to flex those coding muscles. 💪💪

Hopefully by this point we’ve managed to convince ourselves that solutions to this puzzle exist and they can be found at the very least through exhaustive search. But it’s one thing to say you can do something and an entirely different thing to actually do it.

In this third part of the series I hope to present an acceptable programmatic method of finding all the solutions to the puzzle. The approach I’ll be taking has the fancy name Backtracking Search but should be easy to follow even without a history in programming.

You can read Part I here: https://newtonmigosi.medium.com/an-additive-game-part-i-b8a6a2935ae3
And Part…

One solution to the puzzle.

We left Part I having found one solution that fits the rules, but we didn’t come up with a general way to find more solutions. The method of swapping cards was also arbitrary depending on unspecified heuristics.

Let’s take some time to review the problem again:

  • We have been given 12 cards, numbered 1 through to 13 excluding 12.
  • We need to divide the cards into 4 buckets making sure to use up all the cards.
  • A card may be shared by a maximum of two buckets, and no two buckets can share more than one card.
  • When we add…

A set of poker cards laid out in a grid.
A set of poker cards laid out in a grid.
A deck of poker cards.

Here’s a game four people can play using a deck of poker cards.

  • Split the deck by suit and give one to each player.
  • Have every player return their Queen card.
  • Let the game begin!

The objective of this game is to arrange your suit along the edges of a 4x4 square where every edge sums up to 23. For the purposes of our game we’ll take the Ace to have a value of one, the Jack to have a value of eleven and the King to have a value of thirteen.

Getting Started

An initial approach would be to first lay…

Newton Migosi

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store