Skip to content

Instantly share code, notes, and snippets.

@ariG23498
Created July 27, 2018 19:54
Show Gist options
  • Save ariG23498/f4d4f23aafca1d7a924351d957829f90 to your computer and use it in GitHub Desktop.
Save ariG23498/f4d4f23aafca1d7a924351d957829f90 to your computer and use it in GitHub Desktop.
bug crawl mockvita
f = [1, 2, 3, 4, 5, 6]
dir = [['U', 'E', 'D', 'W'], ['U', 'N', 'D', 'S'], ['N', 'E', 'S', 'W'], ['U', 'W', 'D', 'E'], ['U', 'S', 'D', 'N'],
['N', 'W', 'S', 'E']]
face = [[3, 2, 6, 5], [3, 4, 6, 1], [4, 2, 1, 5], [3, 5, 6, 2], [3, 1, 6, 4], [4, 5, 1, 2]]
absolute_dir=['N','W','D','S','E','U']
initial_face = int(input())
initial_dir = input()
directions = input()
prev_face = initial_face
prev_dir = initial_dir
for i in directions:
if i == 'F':
present_face = face[prev_face - 1][dir[prev_face - 1].index((prev_dir))]
present_dir = absolute_dir[prev_face-1]
# print(present_face)
# print(present_dir)
elif i == 'R':
if dir[prev_face-1].index(prev_dir) == 3:
present_face = face[prev_face - 1][0]
present_dir = absolute_dir[prev_face - 1]
else:
present_face = face[prev_face - 1][(dir[prev_face - 1].index((prev_dir)))+1]
present_dir = absolute_dir[prev_face - 1]
# print(present_face)
# print(present_dir)
elif i == 'B':
if dir[prev_face-1].index(prev_dir) == 2:
present_face = face[prev_face - 1][0]
present_dir = absolute_dir[prev_face - 1]
elif dir[prev_face-1].index(prev_dir) == 3:
present_face = face[prev_face - 1][1]
present_dir = absolute_dir[prev_face - 1]
else:
present_face = face[prev_face - 1][(dir[prev_face - 1].index((prev_dir)))+2]
present_dir = absolute_dir[prev_face - 1]
# print(present_face)
# print(present_dir)
elif i == 'L':
if dir[prev_face-1].index(prev_dir) == 1:
present_face = face[prev_face - 1][0]
present_dir = absolute_dir[prev_face - 1]
elif dir[prev_face-1].index(prev_dir) == 2:
present_face = face[prev_face - 1][1]
present_dir = absolute_dir[prev_face - 1]
elif dir[prev_face-1].index(prev_dir) == 3:
present_face = face[prev_face - 1][2]
present_dir = absolute_dir[prev_face - 1]
else:
present_face = face[prev_face - 1][(dir[prev_face - 1].index((prev_dir)))+3]
present_dir = absolute_dir[prev_face - 1]
# print(present_face)
# print(present_dir)
prev_dir=present_dir
prev_face=present_face
print(present_dir)
print(present_face)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment