Day 1
This commit is contained in:
13
1/a.py
Normal file
13
1/a.py
Normal file
@@ -0,0 +1,13 @@
|
||||
with open("input", "r") as f:
|
||||
lines = f.read().splitlines()
|
||||
|
||||
p = 50
|
||||
|
||||
for line in lines:
|
||||
d = line[0]
|
||||
n = int(line[1:])
|
||||
if d == "L":
|
||||
n *= -1
|
||||
p += n
|
||||
p %= 100
|
||||
print(p)
|
||||
16
1/b.py
Normal file
16
1/b.py
Normal file
@@ -0,0 +1,16 @@
|
||||
with open("input", "r") as f:
|
||||
lines = f.read().splitlines()
|
||||
|
||||
p = 50
|
||||
|
||||
for line in lines:
|
||||
d = line[0]
|
||||
n = int(line[1:])
|
||||
|
||||
for i in range(n):
|
||||
if d == "R":
|
||||
p += 1
|
||||
else:
|
||||
p -= 1
|
||||
p %= 100
|
||||
print(p)
|
||||
Reference in New Issue
Block a user