Created
April 5, 2020 09:21
-
-
Save mariokostelac/a865bbcacd05980a8a1ae84d7797c08b 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
i = 0 | |
def dfs(arr, x, y): | |
if x < 0 or x >= len(arr) or y < 0 or y >= len(arr[0]): | |
return | |
if arr[x][y] == 'x': | |
return | |
arr[x][y] = 'x' | |
global i; i+=1 | |
if i % len(arr)-1 == 0: | |
p(arr) | |
dfs(arr, x, y+1) | |
dfs(arr, x-1, y) | |
dfs(arr, x, y-1) | |
dfs(arr, x+1, y) | |
def p(arr): | |
for row in arr: | |
print(''.join(row)) | |
print() | |
arr = [['■']*10 for _ in range(10)] | |
if __name__ == "__main__": | |
p(arr) | |
dfs(arr, 0, 0) |
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
■■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
x■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
xxxxxxxxxx | |
■■■■■■■■■x | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
xxxxxxxxxx | |
xxxxxxxxxx | |
x■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
xxxxxxxxxx | |
xxxxxxxxxx | |
xxxxxxxxxx | |
■■■■■■■■■x | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
xxxxxxxxxx | |
xxxxxxxxxx | |
xxxxxxxxxx | |
xxxxxxxxxx | |
x■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
xxxxxxxxxx | |
xxxxxxxxxx | |
xxxxxxxxxx | |
xxxxxxxxxx | |
xxxxxxxxxx | |
■■■■■■■■■x | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
xxxxxxxxxx | |
xxxxxxxxxx | |
xxxxxxxxxx | |
xxxxxxxxxx | |
xxxxxxxxxx | |
xxxxxxxxxx | |
x■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
xxxxxxxxxx | |
xxxxxxxxxx | |
xxxxxxxxxx | |
xxxxxxxxxx | |
xxxxxxxxxx | |
xxxxxxxxxx | |
xxxxxxxxxx | |
■■■■■■■■■x | |
■■■■■■■■■■ | |
■■■■■■■■■■ | |
xxxxxxxxxx | |
xxxxxxxxxx | |
xxxxxxxxxx | |
xxxxxxxxxx | |
xxxxxxxxxx | |
xxxxxxxxxx | |
xxxxxxxxxx | |
xxxxxxxxxx | |
x■■■■■■■■■ | |
■■■■■■■■■■ | |
xxxxxxxxxx | |
xxxxxxxxxx | |
xxxxxxxxxx | |
xxxxxxxxxx | |
xxxxxxxxxx | |
xxxxxxxxxx | |
xxxxxxxxxx | |
xxxxxxxxxx | |
xxxxxxxxxx | |
■■■■■■■■■x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment