About 13 seconds:
Click here to view the secret text
×666663335555
444699666533
417999656637
777192455577
773392445777
76639914337A
665551A223AA
665513AAAAAA
588133225557
588777765577
558877466667
518874446777
My (messy) code basically does the following:
- have an array of booleans stating whether the number 'z' is not allowed to go in position (x,y) (initially all false)
- have a 'valid' function: for each numbered square, test if there exists a polyomino that fits in the grid and covers that square (considering the current grid and the above array)
- have a 'forced' function: for each question mark, try filling it with a certain number and test if valid returns false. If so, add this to the above array. If all but one number are disallowed for a square, fill it in with the remaining option. Keep repeating this until we can't update anything else.
- extend the above slightly - for each question mark, try filling it with a certain number, then called the forced function and see if the result is still valid. If not, add it to the above array, and repeat.
That doesn't guarantee solving the whole grid, but does in all of these cases (and I expect always would when there's a unique solution).
[Last edited by TripleM at 01-01-2015 02:59 AM]