Skip to content

Commit e863bd6

Browse files
committed
Complete 2015 Day 8
1 parent 453cfe3 commit e863bd6

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

2015/8/2015_08_01.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
# Advent of Code 2015, Day 8: Matchsticks. Part 1
22
# http://adventofcode.com/day/8
33

4+
string_chars = 0 # Initialize variable in global namespace
5+
46

57
def main():
68
solution = 0
7-
for line in open("./2015/7/2015_08.txt", "r", encoding="utf-8"):
8-
pass
9+
for line in open("./2015/8/2015_08.txt", "r", encoding="utf-8"):
10+
code_chars = len(line.strip())
11+
12+
exec(
13+
f"string_chars=len({line.strip()})", globals()
14+
) # Needless to say, don't use exec with untrusted inputs
15+
16+
solution += code_chars - string_chars
917

1018
return f"The resulting number of characters is {solution}"
1119

2015/8/2015_08_02.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Advent of Code 2015, Day 8: Matchsticks. Part 2
2+
# http://adventofcode.com/day/8#part2
3+
4+
string_chars = 0 # Initialize variable in global namespace
5+
6+
7+
def main():
8+
solution = 0
9+
for line in open("./2015/8/2015_08.txt", "r", encoding="utf-8"):
10+
code_chars = len(line.strip())
11+
12+
exec(
13+
f"string_chars=len({line.strip()})", globals()
14+
) # Needless to say, don't use exec with untrusted inputs
15+
16+
solution += code_chars - string_chars
17+
18+
return f"The resulting number of characters is {solution}"
19+
20+
21+
if __name__ == "__main__":
22+
print(main())

0 commit comments

Comments
 (0)