Tom is decorating the pavement in his garden with N square tiles. Each tile is divided into four triangles of different colors (white - 'W', red - 'R', green - 'G' and blue - 'B'). A tile is described as a string of four characters denoting respectively, the color of the upper, right, bottom and left triangle. For example, the tile in the figure below is described as "WRGB".

Tom arranged the tiles in a row and decided to rotate some of them to obtain a pretty sequence. He considers a sequence of tiles pretty if each pair of adjacent tiles shares one side of the same color.
Write a function:
def solution(A)
that, given an array A of N strings, representing the sequence of tiles, returns the minimum number of 90-degree rotations (clockwise or counter-clockwise) that Tom has to perform.
Examples:
1. Given A = ["RGBW", "GBRW"], the function should return 1.

Tom can rotate the second tile counter-clockwise once to obtain a pretty sequence.

2. Given A = ["WBGR", "WBGR", "WRGB", "WRGB", "RBGW"], the function should return 4.

Tom can obtain a pretty sequence by rotating the first and third tiles counter-clockwise and the second and fourth tiles clockwise.

3. Given A = ["RBGW", "GBRW", "RWGB", "GBRW"], the function should return 2.

Tom can rotate the first tile clockwise twice to obtain a pretty sequence.

4. Given A = ["GBRW", "RBGW", "BWGR", "BRGW"], the function should return 2.

Tom can rotate the first two tiles clockwise to obtain a pretty sequence.

Write an efficient algorithm for the following assumptions:
- N is an integer within the range [1..100,000];
- string representing a tile has 4 letters (exactly one occurrence of 'R', 'G', 'B' and 'W').
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def solution(A):
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def solution(A):
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
rotate(A[i])
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def solution(A):
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
rotate(A[i],)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def solution(A):
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
elif:
rotate(A[i],1)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def solution(A):
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
elif ispretty(rotate(A[i],1), A[i+1]):
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def solution(A):
cnt=0
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
elif ispretty(rotate(A[i],1), A[i+1]):
cnt+=1
continue
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def solution(A):
cnt=0
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
elif ispretty(rotate(A[i],1), A[i+1]):
cnt+=1
continue
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
def solution(A):
cnt=0
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
elif ispretty(rotate(A[i],1), A[i+1]):
cnt+=1
continue
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
cnt=0
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
elif ispretty(rotate(A[i],1), A[i+1]):
cnt+=1
continue
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
cnt=0
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
elif ispretty(rotate(A[i],1), A[i+1]):
cnt+=1
continue
elif ispretty(A[i], A[i+1]):
cnt+=1
continue
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
cnt=0
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(rotate(A[i],1), A[i+1]):
cnt+=1
continue
elif ispretty(A[i], A[i+1]):
cnt+=1
continue
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
cnt=0
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(rotate(A[i],1), A[i+1]):
cnt+=1
break
elif ispretty(A[i], A[i+1]):
cnt+=1
continue
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
cnt=0
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(rotate(A[i],j), A[i+1]):
cnt+=1
break
elif ispretty(A[i], A[i+1]):
cnt+=1
continue
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
cnt=0
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(rotate(A[i],j+1), A[i+1]):
cnt+=1
break
elif ispretty(A[i], A[i+1]):
cnt+=2
continue
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
cnt=0
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(rotate(A[i],j+1), A[i+1]):
cnt+=1
break
elif ispretty(A[i], (A[i+1])):
cnt+=2
continue
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
cnt=0
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(rotate(A[i],j+1), A[i+1]):
cnt+=1
break
elif ispretty(A[i], rotate(A[i+1],j+1)):
cnt+=2
continue
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
cnt=0
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(rotate(A[i],j+1), A[i+1]):
cnt+=1
break
elif ispretty(A[i], rotate(A[i+1],j+1)):
cnt+=1
continue
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
cnt=0
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(rotate(A[i],j+1), A[i+1]):
cnt+=1
break
elif ispretty(A[i], rotate(A[i+1],j+1)):
cnt+=1
continue
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
cnt=0
for i in range(4):
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(rotate(A[i],j+1), A[i+1]):
cnt+=1
break
elif ispretty(A[i], rotate(A[i+1],j+1)):
cnt+=1
continue
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
cnt=0
for i in range(4):
A[0] = rotate(A[0],i)
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(rotate(A[i],j+1), A[i+1]):
cnt+=1
break
elif ispretty(A[i], rotate(A[i+1],j+1)):
cnt+=1
continue
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
cnt=0
for i in range(4):
A[0] = rotate(A[0],i)
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
elif ispretty(A[i], rotate(A[i+1],j+1)):
cnt+=1
continue
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
cnt=0
for i in range(4):
A[0] = rotate(A[0],i)
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
cnt+=1
continue
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
cnt=0
for i in range(4):
A[0] = rotate(A[0],i)
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
cnt+=()
continue
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
cnt=0
for i in range(4):
A[0] = rotate(A[0],i)
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
if j==2:
cnt
continue
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
cnt=0
for i in range(4):
A[0] = rotate(A[0],i)
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
if j==2:
cnt+=1
else:
cnt+=j+1
continue
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
cnt=0
for i in range(4):
A[0] = rotate(A[0],i)
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
if j==2:
cnt+=1
else:
cnt+=j+1
break
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
cnt=0
for i in range(4):
A[0] = rotate(A[0],i)
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
if j==2:
cnt+=1
else:
cnt+=j+1
break
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
cnt=0
for i in range(4):
A[0] = rotate(A[0],i)
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
if j==2:
cnt+=1
else:
cnt+=j+1
break
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
cnt=0
for i in range(4):
cnt=0
A[0] = rotate(A[0],i)
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
if j==2:
cnt+=1
else:
cnt+=j+1
break
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
cnt=0
for i in range(4):
cnt=0
A[0] = rotate(A[0],i)
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
if j==2:
cnt+=1
else:
cnt+=j+1
break
answer.append(cnt)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
for i in range(4):
cnt=0
A[0] = rotate(A[0],i)
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
if j==2:
cnt+=1
else:
cnt+=j+1
break
answer.append(cnt)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
for i in range(4):
cnt=0
A[0] = rotate(A[0],i)
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
if j==2:
cnt+=1
else:
cnt+=j+1
break
answer.append(cnt)
return max(answer)
The submission is being evaluated.
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
for i in range(4):
cnt=0
A[0] = rotate(A[0],i)
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
if j==2:
cnt+=1
else:
cnt+=j+1
break
answer.append(cnt)
return max(answer)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
for i in range(4):
cnt=0
A[0] = rotate(A[0],i)
cnt
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
if j==2:
cnt+=1
else:
cnt+=j+1
break
answer.append(cnt)
return max(answer)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
for i in range(4):
cnt=0
A[0] = rotate(A[0],i)
cnt+=i
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
if j==2:
cnt+=1
else:
cnt+=j+1
break
answer.append(cnt)
return max(answer)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
for i in range(4):
cnt=0
A[0] = rotate(A[0],i)
cnt+=i
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
if j==2:
cnt+=1
else:
cnt+=j+1
break
answer.append(cnt)
return max(answer)
The submission is being evaluated.
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
for i in range(4):
cnt=0
A[0] = rotate(A[0],i)
cnt+=i
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
if j==2:
cnt+=1
else:
cnt+=j+1
break
answer.append(cnt)
return max(answer)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
for i in range(4):
cnt=0
A[0] = rotate(A[0],i)
cnt+=i
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
if j==2:
cnt+=1
else:
cnt+=j+1
break
answer.append(cnt)
print(answer)
return max(answer)
The submission is being evaluated.
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
for i in range(4):
cnt=0
A[0] = rotate(A[0],i)
cnt+=i
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
if j==2:
cnt+=1
else:
cnt+=j+1
break
answer.append(cnt)
print(answer)
return min(answer)
The submission is being evaluated.
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
for i in range(4):
cnt=0
A[0] = rotate(A[0],i)
cnt+=i
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
if j==2:
cnt+=1
else:
cnt+=j+1
break
answer.append(cnt)
print(answer)
return min(answer)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
for i in range(4):
cnt=0
A[0] = rotate(A[0],i)
if i==3
cnt+=i
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
if j==2:
cnt+=1
else:
cnt+=j+1
break
answer.append(cnt)
print(answer)
return min(answer)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
for i in range(4):
cnt=0
A[0] = rotate(A[0],i)
if i==3:
cnt+=1
else:
cnt+=i
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
if j==2:
cnt+=1
else:
cnt+=j+1
break
answer.append(cnt)
print(answer)
return min(answer)
The submission is being evaluated.
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
for i in range(4):
cnt=0
A[0] = rotate(A[0],i)
if i==3:
cnt+=1
else:
cnt+=i
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
if j==2:
cnt+=1
else:
cnt+=j+1
break
answer.append(cnt)
print(answer)
return min(answer)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
for i in range(4):
cnt=0
A[0] = rotate(A[0],i)
print(A[0])
if i==3:
cnt+=1
else:
cnt+=i
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
if j==2:
cnt+=1
else:
cnt+=j+1
break
answer.append(cnt)
print(answer)
return min(answer)
The submission is being evaluated.
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
for i in range(4):
cnt=0
A[0] = rotate(A[0],i)
print(A[0])
if i==3:
cnt+=1
else:
cnt+=i
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
if j==2:
cnt+=1
else:
cnt+=j+1
break
answer.append(cnt)
print(answer)
return min(answer)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
initA = A[:]
for i in range(4):
cnt=0
A[0] = rotate(A[0],i)
print(A[0])
if i==3:
cnt+=1
else:
cnt+=i
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
if j==2:
cnt+=1
else:
cnt+=j+1
break
answer.append(cnt)
print(answer)
return min(answer)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
initA = A[:]
for i in range(4):
cnt=0
A[0] = rotate(initA,i)
print(A[0])
if i==3:
cnt+=1
else:
cnt+=i
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
if j==2:
cnt+=1
else:
cnt+=j+1
break
answer.append(cnt)
print(answer)
return min(answer)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
initA = A[:]
for i in range(4):
cnt=0
A[0] = rotate(initA,i)
print(A[0])
if i==3:
cnt+=1
else:
cnt+=i
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
if j==2:
cnt+=1
else:
cnt+=j+1
break
answer.append(cnt)
print(answer)
return min(answer)
The submission is being evaluated.
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
initA = A[:]
for i in range(4):
cnt=0
A[0] = rotate(initA, i)
print(A[0])
if i==3:
cnt+=1
else:
cnt+=i
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
if j==2:
cnt+=1
else:
cnt+=j+1
break
answer.append(cnt)
print(answer)
return min(answer)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
initA = A[0:1]
for i in range(4):
cnt=0
A[0] = rotate(initA, i)
print(A[0])
if i==3:
cnt+=1
else:
cnt+=i
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
if j==2:
cnt+=1
else:
cnt+=j+1
break
answer.append(cnt)
print(answer)
return min(answer)
The submission is being evaluated.
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
initA = A[0]
print()
for i in range(4):
cnt=0
A[0] = rotate(initA, i)
print(A[0])
if i==3:
cnt+=1
else:
cnt+=i
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
if j==2:
cnt+=1
else:
cnt+=j+1
break
answer.append(cnt)
print(answer)
return min(answer)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
initA = A[0]
print(initA, end=':')
for i in range(4):
cnt=0
A[0] = rotate(initA, i)
print(A[0])
if i==3:
cnt+=1
else:
cnt+=i
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
if j==2:
cnt+=1
else:
cnt+=j+1
break
answer.append(cnt)
print(answer)
return min(answer)
The submission is being evaluated.
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
initA = A[0]
for i in range(4):
cnt=0
A[0] = rotate(initA, i)
print(A[0])
if i==3:
cnt+=1
else:
cnt+=i
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
if j==2:
cnt+=1
else:
cnt+=j+1
break
answer.append(cnt)
print(answer)
return min(answer)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
initA = A[0]
for i in range(4):
cnt=0
print(initA, end=':')
A[0] = rotate(initA, i)
print(A[0])
if i==3:
cnt+=1
else:
cnt+=i
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
if j==2:
cnt+=1
else:
cnt+=j+1
break
answer.append(cnt)
print(answer)
return min(answer)
The submission is being evaluated.
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
initA = A[0]
for i in range(4):
cnt=0
A[0] = rotate(initA, i)
print(A[0])
if i==3:
cnt+=1
else:
cnt+=i
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
if j==2:
cnt+=1
else:
cnt+=j+1
break
answer.append(cnt)
print(answer)
return min(answer)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
initA = A[0]
for i in range(4):
cnt=0
A[0] = rotate(initA, i)
if i==3:
cnt+=1
else:
cnt+=i
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
if j==2:
cnt+=1
else:
cnt+=j+1
break
answer.append(cnt)
print(answer)
return min(answer)
The submission is being evaluated.
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
initA = A[0]
for i in range(4):
cnt=0
A[0] = rotate(initA, i)
if i==3:
cnt+=1
else:
cnt+=i
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
if j==2:
cnt+=1
else:
cnt+=j+1
answer.append(cnt)
print(answer)
return min(answer)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
initA = A[0]
for i in range(4):
cnt=0
A[0] = rotate(initA, i)
if i==3:
cnt+=1
else:
cnt+=i
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
if j==2:
cnt+=1
else:
cnt+=j+1
A[i+1] =
answer.append(cnt)
print(answer)
return min(answer)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
initA = A[0]
for i in range(4):
cnt=0
A[0] = rotate(initA, i)
if i==3:
cnt+=1
else:
cnt+=i
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
if j==2:
cnt+=1
else:
cnt+=j+1
A[i+1] = rotate(A[i+1],j+1)
answer.append(cnt)
print(answer)
return min(answer)
The submission is being evaluated.
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
initA = A[0]
for i in range(4):
cnt=0
A[0] = rotate(initA, i)
if i==3:
cnt+=1
else:
cnt+=i
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
pri
if j==2:
cnt+=1
else:
cnt+=j+1
A[i+1] = rotate(A[i+1],j+1)
answer.append(cnt)
print(answer)
return min(answer)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
initA = A[0]
for i in range(4):
cnt=0
A[0] = rotate(initA, i)
if i==3:
cnt+=1
else:
cnt+=i
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
print(j,"번째")
if j==2:
cnt+=1
else:
cnt+=j+1
A[i+1] = rotate(A[i+1],j+1)
answer.append(cnt)
print(answer)
return min(answer)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
initA = A[0]
for i in range(4):
cnt=0
A[0] = rotate(initA, i)
if i==3:
cnt+=1
else:
cnt+=i
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
print(i,"번째", j+1, "돌림")
if j==2:
cnt+=1
else:
cnt+=j+1
A[i+1] = rotate(A[i+1],j+1)
answer.append(cnt)
print(answer)
return min(answer)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
initA = A[0]
for i in range(4):
cnt=0
A[0] = rotate(initA, i)
if i==3:
cnt+=1
else:
cnt+=i
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
print(i+1,"번째", j+1, "돌림")
if j==2:
cnt+=1
else:
cnt+=j+1
A[i+1] = rotate(A[i+1],j+1)
answer.append(cnt)
print(answer)
return min(answer)
The submission is being evaluated.
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
initA = A[0]
for i in range(4):
cnt=0
A[0] = rotate(initA, i)
if i==3:
cnt+=1
else:
cnt+=i
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
print(i+1,"", j+1, "돌림")
if j==2:
cnt+=1
else:
cnt+=j+1
A[i+1] = rotate(A[i+1],j+1)
answer.append(cnt)
print(answer)
return min(answer)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
initA = A[0]
for i in range(4):
cnt=0
A[0] = rotate(initA, i)
if i==3:
cnt+=1
else:
cnt+=i
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
print(i+1,":", j+1, "돌림")
if j==2:
cnt+=1
else:
cnt+=j+1
A[i+1] = rotate(A[i+1],j+1)
answer.append(cnt)
print(answer)
return min(answer)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
initA = A[0]
for i in range(4):
cnt=0
A[0] = rotate(initA, i)
if i==3:
cnt+=1
else:
cnt+=i
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
print(i+1,":", j+1, "rotate")
if j==2:
cnt+=1
else:
cnt+=j+1
A[i+1] = rotate(A[i+1],j+1)
answer.append(cnt)
print(answer)
return min(answer)
The submission is being evaluated.
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
initA = A[0]
for r in range(4):
cnt=0
A[0] = rotate(initA, i)
if i==3:
cnt+=1
else:
cnt+=i
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
print(i+1,":", j+1, "rotate")
if j==2:
cnt+=1
else:
cnt+=j+1
A[i+1] = rotate(A[i+1],j+1)
answer.append(cnt)
print(answer)
return min(answer)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
initA = A[0]
for r in range(4):
cnt=0
A[0] = rotate(initA, r)
if r==3:
cnt+=1
else:
cnt+=r
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
print(i+1,":", j+1, "rotate")
if j==2:
cnt+=1
else:
cnt+=j+1
A[i+1] = rotate(A[i+1],j+1)
answer.append(cnt)
print(answer)
return min(answer)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
initA = A[0]
for r in range(4):
cnt=0
A[0] = rotate(initA, r)
if r==3:
cnt+=1
else:
cnt+=r
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
print(i+1,":", j+1, "rotate")
if j==2:
cnt+=1
else:
cnt+=j+1
A[i+1] = rotate(A[i+1],j+1)
answer.append(cnt)
print(answer)
return min(answer)
The submission is being evaluated.
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
initA = A[0]
for r in range(4):
cnt=0
A[0] = rotate(initA, r)
if r==3:
cnt+=1
else:
cnt+=r
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
print(ri+1,":", j+1, "rotate")
if j==2:
cnt+=1
else:
cnt+=j+1
A[i+1] = rotate(A[i+1],j+1)
answer.append(cnt)
print(answer)
return min(answer)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
initA = A[0]
for r in range(4):
cnt=0
A[0] = rotate(initA, r)
if r==3:
cnt+=1
else:
cnt+=r
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
print(r, ",",i+1,":", j+1, "rotate")
if j==2:
cnt+=1
else:
cnt+=j+1
A[i+1] = rotate(A[i+1],j+1)
answer.append(cnt)
print(answer)
return min(answer)
The submission is being evaluated.
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
initA = A[0]
for r in range(4):
cnt=0
A[0] = rotate(initA, r)
if r==3:
cnt+=1
else:
cnt+=r
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
print(0, r, ",",i+1,":", j+1, "rotate")
if j==2:
cnt+=1
else:
cnt+=j+1
A[i+1] = rotate(A[i+1],j+1)
answer.append(cnt)
print(answer)
return min(answer)
The submission is being evaluated.
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
initA = A[0]
for r in range(4):
cnt=0
A[0] = rotate(initA, r)
if r==3:
cnt+=1
else:
cnt+=r
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
print(0, r, ",",i+1,":", j+1, "rotate")
if j==2:
cnt+=1
else:
cnt+=j+1
A[i+1] = rotate(A[i+1],j+1)
answer.append(cnt)
print(answer)
return min(answer)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
initA = A[0]
for r in range(4):
cnt=0
A[0] = rotate(initA, r)
if r==3:
cnt+=1
else:
cnt+=r
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
print(0, r, ",",i+1,":", j+1, "rotate")
if j==2:
cnt+=1
else:
cnt+=j+1
A[i+1] = rotate(A[i+1],j+1)
answer.append(cnt)
print(answer)
return min(answer)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
initA = A[0]
for r in range(4):
cnt=0
A[0] = rotate(initA, r)
if r==3:
cnt+=1
else:
cnt+=r
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
print(0, r, ",",i+1,":", j+1, "rotate")
if j==2:
cnt+=1
else:
cnt+=j+1
A[i+1] = rotate(A[i+1],j+1)
break
answer.append(cnt)
print(answer)
return min(answer)
The submission is being evaluated.
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
initA = A[0]
for r in range(4):
cnt=0
A[0] = rotate(initA, r)
if r==3:
cnt+=1
else:
cnt+=r
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
print(0, r, ",",i+1,":", j+1, "rotate",)
if j==2:
cnt+=1
else:
cnt+=j+1
A[i+1] = rotate(A[i+1],j+1)
break
answer.append(cnt)
print(answer)
return min(answer)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
initA = A[0]
for r in range(4):
cnt=0
A[0] = rotate(initA, r)
if r==3:
cnt+=1
else:
cnt+=r
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
print(0, r, ",",i+1,":", j+1, "rotate", A[i], A)
if j==2:
cnt+=1
else:
cnt+=j+1
A[i+1] = rotate(A[i+1],j+1)
break
answer.append(cnt)
print(answer)
return min(answer)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
initA = A[0]
for r in range(4):
cnt=0
A[0] = rotate(initA, r)
if r==3:
cnt+=1
else:
cnt+=r
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
print(0, r, ",",i+1,":", j+1, "rotate", A[i], rotate(A[i+1],j+1))
if j==2:
cnt+=1
else:
cnt+=j+1
A[i+1] = rotate(A[i+1],j+1)
break
answer.append(cnt)
print(answer)
return min(answer)
The submission is being evaluated.
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
initA = A[0]
for r in range(4):
cnt=0
A[0] = rotate(initA, r)
if r==3:
cnt+=1
else:
cnt+=r
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
print(0, r, ",",i+1,":", j+1, "rotate", A)
if j==2:
cnt+=1
else:
cnt+=j+1
A[i+1] = rotate(A[i+1],j+1)
break
answer.append(cnt)
print(answer)
return min(answer)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
initA = A[0]
for r in range(4):
cnt=0
A[0] = rotate(initA, r)
if r==3:
cnt+=1
else:
cnt+=r
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
print(0, r, ",",i+1,":", j+1, "rotate", A)
if j==2:
cnt+=1
else:
cnt+=j+1
A[i+1] = rotate(A[i+1],j+1)
break
answer.append(cnt)
print(answer)
return min(answer)
The submission is being evaluated.
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
initA = A[0]
for r in range(4):
cnt=0
A[0] = rotate(initA, r)
if r==3:
cnt+=1
else:
cnt+=r
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
print(0, r, ",",i+1,":", j+1, "rotate", A)
if j==2:
cnt+=1
else:
cnt+=j+1
break
answer.append(cnt)
print(answer)
return min(answer)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(A):
return
def solution(A):
answer=[]
initA = A[0]
for r in range(4):
cnt=0
A[0] = rotate(initA, r)
if r==3:
cnt+=1
else:
cnt+=r
for i in range(len(A)-1):
if ispretty(A[i], A[i+1]):
continue
else:
for j in range(3):
if ispretty(A[i], rotate(A[i+1],j+1)):
A[i+1] = rotate(A[i+1],j+1)
print(0, r, ",",i+1,":", j+1, "rotate", A)
if j==2:
cnt+=1
else:
cnt+=j+1
break
answer.append(cnt)
print(answer)
return min(answer)
The submission is being evaluated.
# you cBn write to stdout for debugging purposes, e.g.
# print("this is B debug messBge")
def rotBte(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else FBlse
def check(B):
return
def solution(B):
Bnswer=[]
initB = B[0]
for r in rBnge(4):
cnt=0
B[0] = rotBte(initB, r)
if r==3:
cnt+=1
else:
cnt+=r
for i in rBnge(len(B)-1):
if ispretty(B[i], B[i+1]):
continue
else:
for j in rBnge(3):
if ispretty(B[i], rotBte(B[i+1],j+1)):
B[i+1] = rotBte(B[i+1],j+1)
print(0, r, ",",i+1,":", j+1, "rotBte", B)
if j==2:
cnt+=1
else:
cnt+=j+1
breBk
Bnswer.Bppend(cnt)
print(Bnswer)
return min(Bnswer)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def check(B):
return
def solution(B):
answer=[]
initA = B[0]
for r in range(4):
cnt=0
B[0] = rotate(initA, r)
if r==3:
cnt+=1
else:
cnt+=r
for i in range(len(B)-1):
if ispretty(B[i], B[i+1]):
continue
else:
for j in range(3):
if ispretty(B[i], rotate(B[i+1],j+1)):
B[i+1] = rotate(B[i+1],j+1)
print(0, r, ",",i+1,":", j+1, "rotate", B)
if j==2:
cnt+=1
else:
cnt+=j+1
break
answer.append(cnt)
print(answer)
return min(answer)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def solution(A):
answer=[]
initA = B[0]
for r in range(4):
cnt=0
B[0] = rotate(initA, r)
if r==3:
cnt+=1
else:
cnt+=r
for i in range(len(B)-1):
if ispretty(B[i], B[i+1]):
continue
else:
for j in range(3):
if ispretty(B[i], rotate(B[i+1],j+1)):
B[i+1] = rotate(B[i+1],j+1)
print(0, r, ",",i+1,":", j+1, "rotate", B)
if j==2:
cnt+=1
else:
cnt+=j+1
break
answer.append(cnt)
print(answer)
return min(answer)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def solution(A):
answer=[]
B=A[:]
initA = B[0]
for r in range(4):
cnt=0
B[0] = rotate(initA, r)
if r==3:
cnt+=1
else:
cnt+=r
for i in range(len(B)-1):
if ispretty(B[i], B[i+1]):
continue
else:
for j in range(3):
if ispretty(B[i], rotate(B[i+1],j+1)):
B[i+1] = rotate(B[i+1],j+1)
print(0, r, ",",i+1,":", j+1, "rotate", B)
if j==2:
cnt+=1
else:
cnt+=j+1
break
answer.append(cnt)
print(answer)
return min(answer)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def solution(A):
answer=[]
B=A[:]
initA = A[0]
for r in range(4):
cnt=0
B[0] = rotate(initA, r)
if r==3:
cnt+=1
else:
cnt+=r
for i in range(len(B)-1):
if ispretty(B[i], B[i+1]):
continue
else:
for j in range(3):
if ispretty(B[i], rotate(B[i+1],j+1)):
B[i+1] = rotate(B[i+1],j+1)
print(0, r, ",",i+1,":", j+1, "rotate", B)
if j==2:
cnt+=1
else:
cnt+=j+1
break
answer.append(cnt)
print(answer)
return min(answer)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def solution(A):
answer=[]
initA = A[0]
for r in range(4):
cnt=0
B=A[:]
B[0] = rotate(initA, r)
if r==3:
cnt+=1
else:
cnt+=r
for i in range(len(B)-1):
if ispretty(B[i], B[i+1]):
continue
else:
for j in range(3):
if ispretty(B[i], rotate(B[i+1],j+1)):
B[i+1] = rotate(B[i+1],j+1)
print(0, r, ",",i+1,":", j+1, "rotate", B)
if j==2:
cnt+=1
else:
cnt+=j+1
break
answer.append(cnt)
print(answer)
return min(answer)
The submission is being evaluated.
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def solution(A):
answer=[]
initA = A[0]
for r in range(4):
cnt=0
B=A[:]
B[0] = rotate(initA, r)
if r==3:
cnt+=1
else:
cnt+=r
for i in range(len(B)-1):
if ispretty(B[i], B[i+1]):
continue
else:
for j in range(3):
if ispretty(B[i], rotate(B[i+1],j+1)):
B[i+1] = rotate(B[i+1],j+1)
if j==2:
cnt+=1
else:
cnt+=j+1
break
answer.append(cnt)
print(answer)
return min(answer)
The submission is being evaluated.
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def solution(A):
answer=[]
initA = A[0]
for r in range(4):
cnt=0
B=A[:]
B[0] = rotate(initA, r)
if r==3:
cnt+=1
else:
cnt+=r
for i in range(len(B)-1):
if ispretty(B[i], B[i+1]):
continue
else:
for j in range(3):
if ispretty(B[i], rotate(B[i+1],j+1)):
B[i+1] = rotate(B[i+1],j+1)
if j==2:
cnt+=1
else:
cnt+=j+1
break
answer.append(cnt)
return min(answer)
The submission is being evaluated.
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def solution(A):
answer=[]
initA = A[0]
for r in range(4):
cnt=0
B=A[:]
B[0] = rotate(initA, r)
if r==3:
cnt+=1
else:
cnt+=r
for i in range(len(B)-1):
if ispretty(B[i], B[i+1]):
continue
else:
for j in range(3):
if ispretty(B[i], rotate(B[i+1],j+1)):
B[i+1] = rotate(B[i+1],j+1)
if j==2:
cnt+=1
else:
cnt+=j+1
break
answer.append(cnt)
return min(answer)
The submission is being evaluated.
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def rotate(s, num):
return s[num:]+s[:num]
def ispretty(s1, s2):
return True if s1[1] == s2[3] else False
def solution(A):
answer=[]
initA = A[0]
for r in range(4):
cnt=0
B=A[:]
B[0] = rotate(initA, r)
if r==3:
cnt+=1
else:
cnt+=r
for i in range(len(B)-1):
if ispretty(B[i], B[i+1]):
continue
else:
for j in range(3):
if ispretty(B[i], rotate(B[i+1],j+1)):
B[i+1] = rotate(B[i+1],j+1)
if j==2:
cnt+=1
else:
cnt+=j+1
break
answer.append(cnt)
return min(answer)
The submission is being evaluated.