Skip to content

Commit a676468

Browse files
committed
Day 01, Part 1
1 parent 427518b commit a676468

File tree

7 files changed

+2033
-0
lines changed

7 files changed

+2033
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.venv

.python-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.10.0

__init__.py

Whitespace-only changes.

day_01/__init__.py

Whitespace-only changes.

day_01/__main__.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env python
2+
3+
from typing import List
4+
from utils import read_number_lines
5+
6+
def count_increases(numbers: List[int]):
7+
"""
8+
>>> count_increases([0, 1, 2, 3])
9+
3
10+
>>> count_increases([0, 0, 0, 0])
11+
0
12+
"""
13+
current = None
14+
count = 0
15+
16+
for num in numbers:
17+
if current is not None and num > current:
18+
count += 1
19+
current = num
20+
return count
21+
22+
if __name__ == "__main__":
23+
import sys
24+
numbers = read_number_lines(sys.stdin)
25+
increases = count_increases(numbers)
26+
print(increases)

0 commit comments

Comments
 (0)