input = open("input", 'r') rotations = [] for i, line in enumerate(input): rotations.append((line[0], int(line[1:]))) password = 0 password_CLICK = 0 dial = 50 # print("The dial starts by pointing at", dial) for direction, length in rotations: clicks = length // 100 length = length % 100 length *= 1 if direction == "R" else -1 dial_new = dial + length if (dial_new <= 0 < dial) or \ (dial < 100 <= dial_new): clicks += 1 dial = dial_new % 100 password_CLICK += clicks if dial == 0: password += 1 # if clicks == 0: # print("The dial is rotated", length, "to point at", dial) # else: # print("The dial is rotated", length, "to point at", dial, # "| during this rotation, it points at 0:", clicks, "times") print(password) print(password_CLICK)