We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
0 parents commit c90c9bfCopy full SHA for c90c9bf
day1.py
@@ -0,0 +1,25 @@
1
+with open("day1_input.txt", "r") as input_file:
2
+ input_string = input_file.read()
3
+
4
+input_lines = input_string.splitlines()
5
6
+digit_lines = []
7
+for line_i in range(len(input_lines)):
8
+ digit_lines.append([])
9
+ for char in input_lines[line_i]:
10
+ if char.isdigit():
11
+ digit_lines[line_i].append(char)
12
13
+print(digit_lines)
14
15
+calibration_values_sum = 0
16
17
+for line in digit_lines:
18
+ if len(line) < 1:
19
+ print(line)
20
+ first_digit = line[0]
21
+ last_digit = line[len(line) - 1]
22
+ number = int(first_digit + last_digit)
23
+ calibration_values_sum += number
24
25
+print("Sum of calibration values: ", calibration_values_sum)
0 commit comments