Skip to content

Instantly share code, notes, and snippets.

Created December 30, 2020 22:12
What would you like to do?
Filtering function for KenKen in PARI/GP
Filters vectors for KenKen game
v: vector
c: Number of elements in the sum (size of the KenKen cell)
n: Maximum value in the sum (length of a side in the game)
u: T/F flag for uniqueness. Set if the cell is contained in a single row or column
e: Exclusion set vector. Numbers appearing in the same row or column as the cell
TF: v satisfies all input conditions
v = [1,2,4];
c = 3;
n = 9;
kFilt(v,c,n) = 1
Written by: John Peach 28-Dec-2020
kFilt(v,c,n,u=1,e=[]) =
length(v) == c &
vecmax(v) <= n &
if(u,isunique(v),1) &
length(setintersect(Set(v),Set(e))) == 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment