File tree Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Original file line number Diff line number Diff line change 1
1
# Advent of Code 2015, Day 8: Matchsticks. Part 1
2
2
# http://adventofcode.com/day/8
3
3
4
+ string_chars = 0 # Initialize variable in global namespace
5
+
4
6
5
7
def main ():
6
8
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
9
17
10
18
return f"The resulting number of characters is { solution } "
11
19
Original file line number Diff line number Diff line change
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 ())
You can’t perform that action at this time.
0 commit comments