diff --git a/brechtje/1/1-1.py b/brechtje/1/1-1.py index 5cc6a11..b208105 100644 --- a/brechtje/1/1-1.py +++ b/brechtje/1/1-1.py @@ -8,11 +8,13 @@ for line in input: pos -= int(line[1:]) elif line.startswith('R'): pos += int(line[1:]) - - if pos < 0: - pos += 100 - elif pos > 99: - pos -= 100 + +# keep subtracting or adding 100 until position is between 0 and 99 + while pos < 0 or pos > 99: + if pos < 0: + pos += 100 + elif pos > 99: + pos -= 100 if pos == 0: password += 1