def inputer(matrix : list,num=2) -> list:
for i in range(num): [matrix.append(i) for i in input() if type(i) == str]
return matrix
valid_moves = {0: [1,2] , 1: [0,3],2:[0,3],3:[2,1]}
def determiner(matrix1 : list, matrix2 : list) -> str:
ind_1= matrix1.index('X')
letter = matrix2[ind_1]
if matrix1.index(letter) in valid_moves[ind_1]:
matrix1[matrix1.index(letter)],matrix1[ind_1] = "X", letter
if matrix1 == matrix2: return "YES"
else: return determiner(matrix1, matrix2)
else:
ticker = 0
while ticker < 4:
first = matrix1[0]
second = matrix1[1]
last = matrix1[2]
third = matrix1[3]
matrix1[0] = last
matrix1[1] = first
matrix1[2] = third
matrix1[3] = second
if matrix1 == matrix2:
return "YES"
ind_1= matrix1.index('X')
letter = matrix2[ind_1]
ticker += 1
if matrix1.index(letter) in valid_moves[ind_1]:
matrix_copy1= matrix1[:]
matrix_copy1[matrix1.index(letter)],matrix_copy1[ind_1] = "X", letter
if matrix_copy1 == matrix2: return "YES"
return "NO"
inputer(matrix1 := [])
inputer(matrix2 := [])
print(determiner(matrix1, matrix2))
1408B - Arrays Sum | 1430A - Number of Apartments |
1475A - Odd Divisor | 1454B - Unique Bid Auction |
978C - Letters | 501B - Misha and Changing Handles |
1496A - Split it | 1666L - Labyrinth |
1294B - Collecting Packages | 1642B - Power Walking |
1424M - Ancient Language | 600C - Make Palindrome |
1669D - Colorful Stamp | 1669B - Triple |
1669A - Division | 1669H - Maximal AND |
1669E - 2-Letter Strings | 483A - Counterexample |
3C - Tic-tac-toe | 1669F - Eating Candies |
1323B - Count Subrectangles | 991C - Candies |
1463A - Dungeon | 1671D - Insert a Progression |
1671A - String Building | 1671B - Consecutive Points Segment |
1671C - Dolce Vita | 1669G - Fall Down |
4D - Mysterious Present | 1316B - String Modification |