-
Notifications
You must be signed in to change notification settings - Fork 0
/
숫자판 점프.py
30 lines (27 loc) · 857 Bytes
/
숫자판 점프.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
def getAllRoute(arr, x,y):
stackArr = [[[x,y], str(arr[y][x])]]
# print("stackArr", stackArr)
result = []
while stackArr:
node = stackArr.pop()
# print("node[1]", node[1])
if len(node[1]) == 6:
result.append(node[1])
else:
dx = [1,-1,0,0]
dy = [0,0,1,-1]
x = node[0][0]
y = node[0][1]
for i in range(4):
xx = x + dx[i]
yy = y + dy[i]
if 0 <= xx < 5 and 0 <= yy < 5:
stackArr.append([[xx,yy], node[1] + str(arr[yy][xx])])
return result
arr = [list(map(int, input().split()))for _ in range(5)]
# print(arr)
routes = set()
for x in range(5):
for y in range(5):
routes = routes.union(getAllRoute(arr, x,y))
print(len(routes))