Datasets:
File size: 555 Bytes
93237a0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | from itertools import combinations
blocked = {(1, 1), (2, 3)}
count = 0
for right_positions in combinations(range(8), 4):
right_positions = set(right_positions)
x = y = 0
valid = True
for step in range(8):
if step in right_positions:
x += 1
else:
y += 1
if (x, y) in blocked:
valid = False
break
if valid:
assert (x, y) == (4, 4)
count += 1
result = {"valid_paths": count}
import json
print(json.dumps(result, ensure_ascii=False, sort_keys=True))
|