I'm trying to create a way to solve a problem where there's a 3x4 table with the 4 corners missing. The goals is to create a algorithm to fill that table with numbers from 1~8 where neither of those numbers can be 1 block close to a cell of it's prior number (eg: 2 can't be close to 1), both in vertical, horizontal and diagonally.
Since I'm new to programing I'm probably doing it the wrong way, I'm generating a list of all the possible placements of the numbers in the cells. But with a 3x4-4 grid it is around 8^8 possible cases(from [1,2,3,4,5,6,7,8] to [8,7,6,5,4,3,2,1])
I'm doing this because my first idea was to make a function to test the data if it matches the criteria afterwards, not requiring to generate the numbers everytime. I'm using pickle to dump the data into a txt file. But the file is 280mb and it freezes my computer for a couple of mintues and then it prints Memory Error.
Sorry if this doesn't make sense, I've started programing a montth ago.
My current code to generate this list is:
for a in xrange(1,9):
for b in xrange(1, 9):
for c in xrange(1, 9):
for d in xrange(1, 9):
for e in xrange(1, 9):
for f in xrange(1, 9):
for g in xrange(1, 9):
for h in xrange(1, 9):
if a != (b and c and d and e and f and g and h) and b != (
a and c and d and e and f and g and h) and c != (
b and a and d and e and f and g and h) and d != (
b and c and a and e and f and g and h) and e != (
b and c and d and a and f and g and h) and f != (
b and c and d and e and a and g and h) and g != (
b and c and d and e and f and a and h) and h != (b and c and d and e and f and g and a):
probs.append((a, b, c, d, e,f,g,h))