Skip to content

Commit 9c1bcf6

Browse files
committed
Update progress helper for new event length
1 parent 6415dfd commit 9c1bcf6

File tree

8 files changed

+562
-166
lines changed

8 files changed

+562
-166
lines changed

.devcontainer/Dockerfile

Lines changed: 0 additions & 31 deletions
This file was deleted.

.devcontainer/devcontainer.json

Lines changed: 0 additions & 24 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ repos:
77
hooks:
88
- id: black
99
- repo: https://github.com/pycqa/isort
10-
rev: 6.1.0
10+
rev: 7.0.0
1111
hooks:
1212
- id: isort
1313
name: isort
@@ -40,6 +40,6 @@ repos:
4040
- id: matlab-reflow-comments
4141
args: [--line-length=100]
4242
- repo: https://github.com/astral-sh/ruff-pre-commit
43-
rev: v0.14.0
43+
rev: v0.14.1
4444
hooks:
4545
- id: ruff-check

2025/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!-- {"python": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], "matlab": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], "rust": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], "lox": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], "julia": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], "go": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]} -->
2+
# Solution Tracker
3+
:x: - Not complete
4+
:white_circle: - Partially complete
5+
:white_check_mark: - Complete
6+
7+
8+
| | Python | MATLAB | Rust | Lox | Julia | Go |
9+
|----|:------------------:|:------------------:|:------------------:|:------------------:|:------------------:|:------------------:|
10+
| 1 | :x: | :x: | :x: | :x: | :x: | :x: |
11+
| 2 | :x: | :x: | :x: | :x: | :x: | :x: |
12+
| 3 | :x: | :x: | :x: | :x: | :x: | :x: |
13+
| 4 | :x: | :x: | :x: | :x: | :x: | :x: |
14+
| 5 | :x: | :x: | :x: | :x: | :x: | :x: |
15+
| 6 | :x: | :x: | :x: | :x: | :x: | :x: |
16+
| 7 | :x: | :x: | :x: | :x: | :x: | :x: |
17+
| 8 | :x: | :x: | :x: | :x: | :x: | :x: |
18+
| 9 | :x: | :x: | :x: | :x: | :x: | :x: |
19+
| 10 | :x: | :x: | :x: | :x: | :x: | :x: |
20+
| 11 | :x: | :x: | :x: | :x: | :x: | :x: |
21+
| 12 | :x: | :x: | :x: | :x: | :x: | :x: |

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ In most cases the provided solutions represent a "first-thoughts" approach to th
1212
## Solution Progress
1313
The table below is [generated](https://github.com/sco1/adventofcode/blob/main/helpers/update_progress.py) from data contained in each year's README.md file. The per-language summary is provided as (full solve, partial solve) pairs.
1414

15+
**NOTE:** Starting in 2025, the length of the event has been shortened to `12` days from `25`.
16+
1517
<!-- [[[cog
1618
from datetime import datetime
1719
@@ -32,6 +34,7 @@ cog.out(f"{build_summary_table()}\n\nLast generated: `{datetime.now()}`")
3234
| `2022` | `19, 2` | ` 4, 0` | ` 1, 0` | ` 0, 0` | ` 1, 0` | ` 0, 0` |
3335
| `2023` | `16, 5` | ` 0, 0` | ` 0, 0` | ` 0, 0` | ` 0, 0` | ` 0, 0` |
3436
| `2024` | `18, 5` | ` 0, 0` | ` 0, 0` | ` 0, 0` | ` 0, 0` | ` 0, 0` |
37+
| `2025` | ` 0, 0` | ` 0, 0` | ` 0, 0` | ` 0, 0` | ` 0, 0` | ` 0, 0` |
3538

36-
Last generated: `2024-12-28 21:40:47.113947`
39+
Last generated: `2025-10-22 12:10:01.261504`
3740
<!-- [[[end]]] -->

helpers/update_progress.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ class State(IntEnum): # noqa: D101
4141
DATA_T: t.TypeAlias = dict[str, list[State]]
4242

4343

44-
def build_table(data: DATA_T) -> str: # noqa: D103
44+
def build_table(data: DATA_T, n_days: int) -> str: # noqa: D103
4545
header = f"| |{'|'.join(la.title().center(MIN_WIDTH+2) for la in Lang)}|"
4646
header = header.replace("Matlab", "MATLAB") # Special case name
4747

4848
sub_div = f":{'-'*MIN_WIDTH}:|"
4949
divider = f"|----|{sub_div*len(Lang)}"
5050

5151
rows = []
52-
for day in range(25):
52+
for day in range(n_days):
5353
rows.append(
5454
f"|{day+1:^4}|{'|'.join(ICONS[data[la][day]].center(MIN_WIDTH+2) for la in Lang)}|"
5555
)
@@ -58,15 +58,15 @@ def build_table(data: DATA_T) -> str: # noqa: D103
5858
return f"{header}\n{divider}\n{all_rows}"
5959

6060

61-
def ensure_lang(data: DATA_T) -> DATA_T:
61+
def ensure_lang(data: DATA_T, n_days: int) -> DATA_T:
6262
"""Ensure that the data table contains all the languages defined by `Lang`."""
6363
for lang in Lang - data.keys():
64-
data[lang] = [State.NOT] * 25
64+
data[lang] = [State.NOT] * n_days
6565

6666
return data
6767

6868

69-
def parse_progress_json(filepath: Path) -> DATA_T:
69+
def parse_progress_json(filepath: Path, n_days: int) -> DATA_T:
7070
"""
7171
Parse the progress data from the provided README file.
7272
@@ -80,9 +80,9 @@ def parse_progress_json(filepath: Path) -> DATA_T:
8080
data_table = json.loads(
8181
first_line.rstrip().removeprefix("<!--").removesuffix("-->").strip()
8282
)
83-
data_table = ensure_lang(data_table)
83+
data_table = ensure_lang(data_table, n_days=n_days)
8484
else:
85-
data_table = {lang.value: ([State.NOT] * 25) for lang in Lang}
85+
data_table = {lang.value: ([State.NOT] * n_days) for lang in Lang}
8686

8787
return data_table # type: ignore[no-any-return]
8888

@@ -99,7 +99,14 @@ def build_summary_table() -> str:
9999
rows = []
100100
for filepath in sorted(BASE_DIR.glob("2*/README.md"), key=lambda x: x.parent):
101101
year = filepath.parent.name
102-
data = parse_progress_json(filepath)
102+
103+
# Starting in 2025, the event is 12 long days rather than the historical 25
104+
if int(year) >= 2025:
105+
n_days = 12
106+
else:
107+
n_days = 25
108+
109+
data = parse_progress_json(filepath, n_days=n_days)
103110

104111
row = []
105112
for la in Lang:
@@ -123,15 +130,21 @@ def main() -> None: # noqa: D103
123130

124131
args = parser.parse_args()
125132

133+
# Starting in 2025, the event is 12 long days rather than the historical 25
134+
if args.year >= 2025:
135+
n_days = 12
136+
else:
137+
n_days = 25
138+
126139
filepath = BASE_DIR / f"{args.year}" / "README.md"
127-
data_table = parse_progress_json(filepath)
140+
data_table = parse_progress_json(filepath, n_days=n_days)
128141

129142
data_table[args.lang][args.day - 1] = State[args.state.upper()]
130143

131144
with filepath.open("w") as f:
132145
f.write(f"<!-- {json.dumps(data_table)} -->\n")
133146
f.write(f"{HEADER}\n\n")
134-
f.write(f"{build_table(data_table)}\n")
147+
f.write(f"{build_table(data_table, n_days=n_days)}\n")
135148
print(f"Puzzle status updated: ({args.year}, {args.day}, {args.lang}, {args.state})")
136149

137150
# Update the base README with the new status using Cog & a dummy sys.argv

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ readme = "README.md"
1010

1111
requires-python = ">=3.12"
1212
dependencies = [
13+
"ipykernel~=7.0",
1314
"more-itertools~=10.4",
1415
"networkx~=3.3",
1516
"numpy~=2.1",
@@ -35,7 +36,7 @@ dev = [
3536
"flake8~=7.1",
3637
"flake8-annotations~=3.1",
3738
"flake8-define-class-attributes~=0.2",
38-
"isort~=6.0",
39+
"isort~=7.0",
3940
"mypy~=1.11",
4041
"pre-commit~=4.0",
4142
"pytest~=8.3",

0 commit comments

Comments
 (0)