Days 1 and 2
Day 2 removed input from day 1
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
input
|
||||
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)
|
||||
16
2/a.py
Normal file
16
2/a.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import re
|
||||
|
||||
with open("input", "r") as f:
|
||||
line = f.read()
|
||||
|
||||
ranges = line.split(",")
|
||||
|
||||
s = 0
|
||||
|
||||
for _range in ranges:
|
||||
start, end = list(map(int, _range.split("-")))
|
||||
for i in range(start, end+1):
|
||||
if re.match(r"^(.+)\1$", str(i)):
|
||||
s += i
|
||||
|
||||
print(s)
|
||||
Reference in New Issue
Block a user