import sys from typing import List DIAL_START = 50 dial = [0] * 100 def parseString(filename: str) -> List[str]: with open(filename, 'r') as file: file_content = file.read() return file_content.strip().splitlines() def do_move(move: str, position: int) -> int: # takes in string if move[0] == 'L': # turn left position -= int(move[1:]) elif move[0] == 'R': # turn right position += int(move[1:]) position %= 100 print("position:", position) dial[position] += 1 return position def main() -> int: instructions = parseString(sys.argv[1]) position = DIAL_START for i in instructions: position = do_move(i, position) return dial[0] if __name__ == "__main__": print(main())