Created
December 17, 2019 06:16
-
-
Save terrycojones/68f25db52f9158396952b2a4cf4b8be8 to your computer and use it in GitHub Desktop.
This file contains 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 | |
l = len(a) | |
for p in range(0, l - 1): | |
if p + s * 2 < l: | |
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 | |
else: | |
break | |
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