Created
December 3, 2025 22:43
-
-
Save jmikkola/129e8c796714939d40b599d2d369192c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import sys | |
| args = sys.argv[1:] | |
| if args: | |
| fname = args[0] | |
| else: | |
| fname = 'test' | |
| with open(fname) as inf: | |
| lines = inf.readlines() | |
| n_zeros = 0 | |
| n_crosses = 0 | |
| dial = 50 | |
| for line in lines: | |
| line = line.replace('R', '').replace('L', '-') | |
| change = int(line) | |
| value = abs(change) | |
| sign = change / value | |
| for _ in range(value): | |
| dial = (dial + sign) % 100 | |
| if dial == 0: | |
| n_crosses += 1 | |
| if dial == 0: | |
| n_zeros += 1 | |
| print(n_zeros, n_crosses) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment