Created
August 5, 2018 19:42
-
-
Save fl64/c1afaf84e53bf726743e2cd1f5e3caa3 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
matrix = [[0 for x in range(8)] for x in range(8)] | |
move = ((1,0), (0,1), (-1,0), (0,-1)) | |
f=0 | |
x=0 | |
y=0 | |
z=1 | |
def mp (): | |
for i in matrix: | |
print(i) | |
print() | |
mp() | |
matrix[x][y]=z | |
while 1: | |
if f > 1: break | |
for steps in move: | |
while 1: | |
x1 = x + steps[0] | |
y1 = y + steps[1] | |
if (steps[0] and x1 > 7) or (steps[1] and y1 > 7): | |
f+=1 | |
break | |
if matrix[x1][y1]>0: | |
f+=1 | |
break | |
f=0 | |
z+=1 | |
matrix[x1][y1]=z | |
x=x1 | |
y=y1 | |
mp() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment