Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- size = int(input())
- racing_number = input()
- matrix = []
- tunel_pos = []
- distance = 0
- for row in range(size):
- line = input().split()
- matrix.append(line)
- if 'T' in line:
- tunel_pos = [row, line.index('T')]
- command = input()
- row, col = 0, 0
- while 0 <= row < size and 0 <= col < size:
- if matrix[row][col] == "T":
- distance += 20
- tunel_pos = "."
- matrix[row][col] = "."
- temp = row
- row = col
- col = temp
- if matrix[row][col] == "F":
- matrix[row][col] = "C"
- print(f"Racing car {racing_number} finished the stage!")
- break
- if command == 'up':
- row -= 1
- distance += 10
- elif command == 'down':
- row += 1
- distance += 10
- elif command == 'left':
- col -= 1
- distance += 10
- elif command == 'right':
- col += 1
- distance += 10
- if command == "End":
- print(f"Racing car {racing_number} DNF.")
- break
- command = input()
- if distance:
- print(f"Distance covered {distance} km." )
- for m_line in matrix:
- print("".join(m_line))
Advertisement
Add Comment
Please, Sign In to add comment