Astute readers will recognise this as an example of a finite projective plane, and may also recognise the set of cards as being similar to the game Doppel or Spot It!
Jim Randell produced a Python module to generate a set of cards, and a similar Python program by Joel Grus can be found here
I thought I would try to produce a Python version that allows sets of cards to be produced based on a projective plane associated with a finite field of the form GF(p^n) for arbitrary prime p an positive integer n.
The tricky bit if being able to do multiplication in the finite field, which requires an irreducible polynomial of degree n over the field. My code achieves this for values of n up to 3, and for a few other combinations of p and n that have pre-calculated irreducibles.
The code can be found here. It consists of
- a general purpose finite field module (adapted from the one I created for Sunday Times Teaser 777 )
- a module to generate sets of cards based on the projective plane of GF(p^n)
No comments:
Post a Comment