Paste Search Dynamic
Recent pastes
check turn
  1. def check_turn(i):
  2.     if i+1 < 4:
  3.         if turn[i+1] == 0 and a[i][2] != a[i+1][6]:
  4.             turn[i+1] = turn[i] * -1
  5.             check_turn(i+1)
  6.     if i-1 >= 0:
  7.         if turn[i-1] == 0 and a[i][6] != a[i-1][2]:
  8.             turn[i-1] = turn[i] * -1
  9.             check_turn(i-1)
  10.  
  11.  
  12. a = []
  13. for _ in range(4):
  14.     row = list(map(int, input().strip()))
  15.     a.append(row)
  16.  
  17. k = int(input())
  18. for _ in range(k):
  19.     idx, dir = map(int, input().split())
  20.     turn = [0 for _ in range(4)]
  21.     turn[idx-1] = dir
  22.     check_turn(idx-1)
  23.     print(turn)
  24.     for i in range(4):
  25.         if turn[i] == 0:
  26.             continue
  27.         temp = [0 for _ in range(8)]
  28.         if turn[i] == 1:
  29.             for j in range(7):
  30.                 temp[j+1] = a[i][j]
  31.             temp[0] = a[i][7]
  32.         elif turn[i] == -1:
  33.             for j in range(7, 0, -1):
  34.                 temp[j-1] = a[i][j]
  35.             temp[7] = a[i][0]
  36.         a[i] = temp
  37.  
  38. ans = 0
  39. for i in range(4):
  40.     ans += a[i][0] * pow(2, i)
  41. print(ans)
Parsed in 0.005 seconds