Skip to content

Commit

Permalink
2024-08-10 주사위굴리기
Browse files Browse the repository at this point in the history
  • Loading branch information
seongwon030 committed Aug 10, 2024
1 parent 67538f5 commit 68665a8
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions seongwon030/구현/주사위굴리기.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import sys
input = sys.stdin.readline

n,m,x,y,k = map(int,input().split())
arr = []
for _ in range(n):
arr.append(list(map(int,input().split())))

move = list(map(int,input().split()))

# 주사위 (서,북,윗면,오,남,아랫면) 초기값
dice = [0]*6
# k=1, 동쪽으로 이동
# k=2, 서쪽으로 이동
# k=3, 북쪽으로 이동
# k=4, 남쪽으로 이동

for i in move:
if i == 1: # 동
if y+1 < m:
y+=1
dice[0],dice[2],dice[3],dice[5] = dice[5],dice[0],dice[2],dice[3]
print(dice[2])
if arr[x][y] == 0:
arr[x][y] = dice[5]
else:
dice[5] = arr[x][y]
arr[x][y] = 0
elif i == 2: # 서
if y-1 >=0:
y-=1
dice[0],dice[2],dice[3],dice[5] = dice[2],dice[3],dice[5],dice[0]
print(dice[2])
if arr[x][y] == 0:
arr[x][y] = dice[5]
else:
dice[5] = arr[x][y]
arr[x][y] = 0
elif i == 3: # 북
if x-1 >=0:
x-=1
dice[1],dice[2],dice[4],dice[5] = dice[2],dice[4],dice[5],dice[1]
print(dice[2])
if arr[x][y] == 0:
arr[x][y] = dice[5]
else:
dice[5] = arr[x][y]
arr[x][y] = 0
elif i == 4: # 남
if x+1 < n:
x+=1
dice[1],dice[2],dice[4],dice[5] = dice[5],dice[1],dice[2],dice[4]
print(dice[2])
if arr[x][y] == 0:
arr[x][y] = dice[5]
else:
dice[5] = arr[x][y]
arr[x][y] = 0

0 comments on commit 68665a8

Please sign in to comment.