↓Skip to main content

How Sudoku Saved an Experiment

·2 mins

My girlfriend, a researcher in animal nutrition, pitched an interesting problem to me. Her task was to create a feeding plan for four pigs with six different types of feed, with the following constraints:

  1. Each pig must receive its feeds in a different order.
  2. On a day of testing, no two pigs should receive the same feed.

My first idea was to start off each pig with a different feed, shifting every pig’s feed each day. Unfortunately, this was still undesirable: even though each pig started and ended with a different feed, the overall order remained the same, which created a risk of carry-over effects.

After the two of us had pondered it for a while, the answer dawned on me while I was staring at an empty spreadsheet. I had heard enough lectures on complexity theory in the past two semesters to scratch just that itch: What if I were to reduce this problem to a different, known problem?

Sudoku to the rescue #

The excellent Libre-Sudoku app for Android allows one to generate 6x6 playing fields. All that had to be done was to solve the puzzle, trim the playing field to the number of pigs in the experiment, and map integers to the specific feeds.

FTNP
PBB+LB+HL
B+HLP+LP+HLB+L
B+LP+HLBP
P+LPB+HLB
BB+LP+LP+HL
B+HLP+HLPP+L

The trimmed table maps perfectly onto the four pigs used (abbreviated to F, T, N, and P), with each row specifying the feed types (P, B, B+L, P+L, B+HL, P+HL) to be used on a given day of the experiment.

Surely there is a more direct way to solve this problem as a CSP, but in the heat of the moment, Sudoku did the trick.