Created
December 17, 2019 07:17
-
-
Save terrycojones/693d9f6ddfa90265350f40a0e61b3950 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def solve1(n, a): | |
s = n + 1 | |
for p in range(len(a) - 2 * s): | |
if a[p] + a[p + s] + a[p + s + s] == 0: | |
a[p] = a[p + s] = a[p + s + s] = n | |
if n > 1: | |
solve1(n - 1, a) | |
else: | |
print(''.join(map(str, a))) | |
a[p] = a[p + s] = a[p + s + s] = 0 | |
def solve(n): | |
solve1(n, [0] * n * 3) | |
solve(9) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment