Skip to content

Instantly share code, notes, and snippets.

@fl64
Created August 5, 2018 19:42
Show Gist options
  • Save fl64/c1afaf84e53bf726743e2cd1f5e3caa3 to your computer and use it in GitHub Desktop.
Save fl64/c1afaf84e53bf726743e2cd1f5e3caa3 to your computer and use it in GitHub Desktop.
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