Skip to content

Commit 9a5e9e6

Browse files
authored
use pip-compile to generate requirements.txt (#37)
* use pip-compile to generate requirements.txt * re-run black on all code seems like some rules changed while upgrading from 22.12 to 23.x * dont emit index url
1 parent b0cf731 commit 9a5e9e6

File tree

24 files changed

+77
-46
lines changed

24 files changed

+77
-46
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,9 @@ To benchmark one of the modules with `timeit`, can run something like:
1818
python -m timeit -s 'import y2021.problem15; inp = open("y2021/problem15/input").read(-1).strip()' 'y2021.problem15.part1(inp)'
1919
1 loop, best of 5: 938 msec per loop
2020
```
21+
22+
The `requirements.txt` file is generated with pip-compile from [pip-tools](https://pip-tools.readthedocs.io/en/latest/). To re-compile:
23+
24+
```
25+
pip-compile --no-emit-index-url > requirements.txt
26+
```

requirements.in

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
black
2+
mypy
3+
pytest
4+
tox

requirements.txt

+62-26
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,68 @@
1-
attrs==22.1.0
2-
black==22.12.0
3-
cachetools==5.2.0
4-
cfgv==3.3.1
1+
#
2+
# This file is autogenerated by pip-compile with Python 3.10
3+
# by the following command:
4+
#
5+
# pip-compile --no-emit-index-url
6+
#
7+
attrs==22.2.0
8+
# via pytest
9+
black==23.1.0
10+
# via -r requirements.in
11+
cachetools==5.3.0
12+
# via tox
513
chardet==5.1.0
14+
# via tox
615
click==8.1.3
16+
# via black
717
colorama==0.4.6
18+
# via tox
819
distlib==0.3.6
9-
exceptiongroup==1.0.4
10-
filelock==3.8.2
11-
identify==2.5.9
12-
iniconfig==1.1.1
13-
mypy==0.991
14-
mypy-extensions==0.4.3
15-
nodeenv==1.7.0
16-
packaging==22.0
17-
pathspec==0.10.2
18-
platformdirs==2.6.0
20+
# via virtualenv
21+
exceptiongroup==1.1.0
22+
# via pytest
23+
filelock==3.9.0
24+
# via
25+
# tox
26+
# virtualenv
27+
iniconfig==2.0.0
28+
# via pytest
29+
mypy==1.0.1
30+
# via -r requirements.in
31+
mypy-extensions==1.0.0
32+
# via
33+
# black
34+
# mypy
35+
packaging==23.0
36+
# via
37+
# black
38+
# pyproject-api
39+
# pytest
40+
# tox
41+
pathspec==0.11.0
42+
# via black
43+
platformdirs==3.0.0
44+
# via
45+
# black
46+
# tox
47+
# virtualenv
1948
pluggy==1.0.0
20-
pre-commit==2.20.0
21-
py==1.11.0
22-
pyparsing==3.0.9
23-
pyproject_api==1.2.1
24-
pytest==7.2.0
25-
PyYAML==6.0
26-
six==1.16.0
27-
toml==0.10.2
49+
# via
50+
# pytest
51+
# tox
52+
pyproject-api==1.5.0
53+
# via tox
54+
pytest==7.2.1
55+
# via -r requirements.in
2856
tomli==2.0.1
29-
tox==4.0.8
30-
typed-ast==1.5.4
31-
typing_extensions==4.4.0
32-
virtualenv==20.17.1
57+
# via
58+
# black
59+
# mypy
60+
# pyproject-api
61+
# pytest
62+
# tox
63+
tox==4.4.6
64+
# via -r requirements.in
65+
typing-extensions==4.5.0
66+
# via mypy
67+
virtualenv==20.19.0
68+
# via tox

y2020/problem06/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33

44
def count_groups(inp: str, intersect=False) -> int:
5-
65
groups = inp.strip().split("\n\n")
76

87
all_answers: List[Set[str]] = []

y2020/problem10/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
# joltage differences between the charging outlet, the adapters, and your
2323
# device?
2424

25+
2526
# Originally my solution tried to find a valid chain of adapters from the input
2627
# which would use all of them. But duh, if we use all of them, there is only one
2728
# ordering possible, since the allowed differences of [1, 2, or 3] are all

y2020/problem12/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ def part1(instr: List[str]) -> Tuple[int, int]:
4646

4747

4848
def move(pos: Tuple[int, int], action: str, value: int) -> Tuple[int, int]:
49-
5049
if action == "N":
5150
r = pos[0], pos[1] - value
5251
elif action == "S":

y2020/problem17/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ def part1(inp: str, cycles: int = 6) -> int:
7979

8080

8181
def print_state3(state: State3):
82-
8382
min_z = min(z for x, y, z in state)
8483
max_z = max(z for x, y, z in state)
8584

y2020/problem18/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ def parse_expression(line: str, part1=True) -> List[Either]:
5151

5252
# check if operator
5353
elif token not in ["(", ")"]:
54-
5554
while (
5655
len(operators) > 0
5756
# normally this would also check if operator at the top of the

y2020/problem20/__init__.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
Position = Tuple[int, int]
88
Image = Dict[Position, Tile]
99

10+
1011
# some thoughts on an approach:
1112
#
1213
# only the borders of each tile matter
@@ -196,7 +197,6 @@ def assert_image_valid(image: Image):
196197
def assemble_image(
197198
tiles: Dict[int, Tile], corner_tile_nums: Set[int]
198199
) -> Tuple[Image, Dict[Position, int]]:
199-
200200
# dict of border (string) to count (int)
201201
border_counts = Counter(b for t in tiles.values() for b in all_borders(t))
202202

@@ -372,7 +372,6 @@ def count_sea_monsters(tile: Tile) -> int:
372372
# of the monster onto it (with the last group being rows [93,94,95]).
373373
for y in range(0, tile_rows - monster_rows + 1):
374374
for x in range(0, tile_cols - monster_cols + 1):
375-
376375
# using (x, y) as an anchor point, we see if the monster could exist
377376
# from this anchor point. Do this by checking if the positions from
378377
# here contain the required '#' characters.

y2020/problem20/test_problem20.py

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ def tiles():
1212

1313

1414
def test_parse_input(tiles):
15-
1615
assert len(tiles) == 144
1716
for tile in tiles.values():
1817
assert len(tile) == 10

y2020/problem22/__init__.py

-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ def parse_input(inp: str) -> Tuple[Deck, Deck]:
4848
def play_game(
4949
deck1: Deck, deck2: Deck, max_rounds: Optional[int] = None
5050
) -> Tuple[Deck, Deck]:
51-
5251
# make copies
5352
deck1 = list(deck1)
5453
deck2 = list(deck2)
@@ -104,7 +103,6 @@ def score(winning_deck: Deck) -> int:
104103
def play_game2(
105104
deck1: Deck, deck2: Deck, max_rounds: Optional[int] = None, game_num: int = 1
106105
) -> Tuple[Deck, Deck, int]:
107-
108106
# make copies
109107
deck1 = list(deck1)
110108
deck2 = list(deck2)

y2020/problem24/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ def process_moves(inp: str) -> Set[Position]:
7676
black_tiles: Set[Position] = set()
7777

7878
for line in inp.strip().split("\n"):
79-
8079
pos = (0, 0)
8180

8281
for m in parse_line(line):

y2020/problem25/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ def transform_n_times(subject: int, loop_size: int) -> int:
8383

8484

8585
def part1(inp: str) -> int:
86-
8786
card_pub_key, door_pub_key = map(int, inp.strip().split("\n"))
8887

8988
# what loop size would have generated the two pub keys?

y2021/problem01/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from typing import *
22

3+
34
# The first order of business is to figure out how quickly the depth increases,
45
# just so you know what you're dealing with - you never know if the keys will
56
# get carried into deeper water by an ocean current or a fish or something.

y2021/problem04/test_problem04.py

-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ def test_board_col():
6363

6464

6565
def test_part1_example():
66-
6766
assert part1(example) == 4512
6867

6968

y2021/problem07/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
# Determine the horizontal position that the crabs can align to using the least
3838
# fuel possible. How much fuel must they spend to align to that position?
3939

40+
4041
# -----------------------------------------------------------------------------
4142
# My notes:
4243
#

y2021/problem09/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ def part1(inp: str):
9393
# The size of a basin is the number of locations within the basin, including the
9494
# low point. The example above has four basins.
9595
def part2(inp: str):
96-
9796
g = Grid(inp)
9897

9998
basins: List[Set[Pos]] = []

y2021/problem14/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ def parse(inp: str) -> Tuple[str, Dict[str, str]]:
1414

1515

1616
def run_steps(template: str, instructions: Dict[str, str], rounds=10) -> Dict[str, int]:
17-
1817
# the naive approach, which works fine for part1 / 10 rounds, is to treat
1918
# the polymer as a string (or list of chars), build a copy of the string in
2019
# each round, iterating over each position in the string. around round 20

y2022/problem01/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from typing import *
22

3+
34
# In case the Elves get hungry and need extra snacks, they need to know which
45
# Elf to ask: they'd like to know how many Calories are being carried by the Elf
56
# carrying the most Calories. In the example above, this is 24000 (carried by

y2022/problem10/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33

44
def part1(inp: str):
5-
65
# Start by figuring out the signal being sent by the CPU. The CPU has a
76
# single register, X, which starts with the value 1. It supports only two
87
# instructions:

y2022/problem12/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ def build_graph(height: Dict[Node, int]) -> Dict[Node, List[Node]]:
7878
def solve(
7979
height: Dict[Node, int], graph: Dict[Node, List[Node]], start: Node, end: Node
8080
) -> Optional[int]:
81-
8281
# now we search
8382
def h(n: Node) -> int:
8483
return abs(n[0] - end[0]) + abs(n[1] - end[1])

y2022/problem15/__init__.py

-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ def parse(inp: str) -> List[Tuple[Point, Point]]:
2626

2727

2828
def part1(inp: str, y=2000000) -> int:
29-
3029
# First approach I took here was to attempt to populate a sparse grid to
3130
# note every (x, y) position where a sensor is, where the beacons are, and
3231
# the positions that cannot contain a beacon. This works well for the
@@ -78,7 +77,6 @@ def part1(inp: str, y=2000000) -> int:
7877

7978

8079
def part2(inp: str, search_space: Tuple[int, int]) -> int:
81-
8280
# Your handheld device indicates that the distress signal is coming from a
8381
# beacon nearby. The distress beacon is not detected by any sensor, but the
8482
# distress beacon must have x and y coordinates each no lower than 0 and no

y2022/problem16/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ def parse(inp: str) -> Tuple[Dict[str, int], Dict[str, List[str]]]:
2626

2727

2828
def part1(inp: str, minutes: int = 30, start_location="AA"):
29-
3029
flow_rate, connections = parse(inp)
3130

3231
@functools.cache

y2022/problem17/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ def next_rock(
7979
shape_gen: Iterator[Shape],
8080
jet_gen: Iterator[str],
8181
) -> int:
82-
8382
# new rock
8483
shape = next(shape_gen)
8584
# Each rock appears so that its left edge is two units away from the

0 commit comments

Comments
 (0)