adventofcode 25.2__tar.gz → 25.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,6 +5,23 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Calendar Versioning](https://calver.org).
7
7
 
8
+ ## [25.4]
9
+
10
+ ### Added
11
+
12
+ * New `uv run adventofcode run` command that removes the need for boilerplate in your solutions.
13
+
14
+ ### Fixed
15
+
16
+ * Outputs are now cleaner and less verbose.
17
+ * Generated templates with `uv run adventofcode init` now include a docstring with instructions on how to run it. All the AoC class boilerplate has been removed.
18
+
19
+ ## [25.3]
20
+
21
+ ### Fixed
22
+
23
+ * Missing `uv run` commands in README. Thank you @baloncek2662! ❤️
24
+
8
25
  ## [25.2]
9
26
 
10
27
  ### Added
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: adventofcode
3
- Version: 25.2
3
+ Version: 25.4
4
4
  Summary: Helper utilities for solving Advent of Code puzzles
5
5
  Project-URL: Documentation, https://github.com/anze3db/adventofcode#readme
6
6
  Project-URL: Issues, https://github.com/anze3db/adventofcode/issues
@@ -31,11 +31,10 @@ Description-Content-Type: text/markdown
31
31
 
32
32
  Helper utilities for solving Advent of Code puzzles.
33
33
 
34
- * Project scaffolding with `adventofcode init`
35
- * Benchmark all the days with `adventofcode benchmark`
36
- * No copy-pasting puzzle inputs into files.
37
- * No need to use low-level file APIs to read your inputs.
38
- * Performance reports for example inputs and puzzle inputs.
34
+ * Project scaffolding with `uv run adventofcode init`
35
+ * Assert and submit your solutions with `uv run adventofcode run`
36
+ * Benchmark all your solutions with `uv run adventofcode benchmark`
37
+ * No copy-pasting puzzle inputs or loading inputs from files.
39
38
  * Submit the answer immediately when your code returns the result 🏅
40
39
 
41
40
  ## Usage
@@ -45,7 +44,7 @@ Helper utilities for solving Advent of Code puzzles.
45
44
  ```bash
46
45
  uv init
47
46
  uv add adventofcode
48
- adventofcode init
47
+ uv run adventofcode init
49
48
  ```
50
49
 
51
50
  This will generate the scripts for each day:
@@ -72,58 +71,78 @@ This will generate the scripts for each day:
72
71
  1 directory, 16 files
73
72
  ```
74
73
 
75
- All the py files look like this:
74
+ All the generated Python files look like this:
76
75
 
77
76
  ```python
78
- from adventofcode import AoC
77
+ """🎄 Solution for Day 1 of Advent of Code 2025 🎄
79
78
 
79
+ Usage:
80
80
 
81
- def part1(inp: str):
82
- return None
81
+ uv run adventofcode run 01.py
82
+ """
83
83
 
84
+ inp = """your input"""
85
+ part1_asserts = [
86
+ (inp, None),
87
+ ]
88
+ part2_asserts = [
89
+ (inp, None),
90
+ ]
84
91
 
85
- def part2(inp: str):
92
+
93
+ def part1(inp: str) -> str | int | None:
86
94
  return None
87
95
 
88
96
 
89
- aoc = AoC(part_1=part1, part_2=part2)
90
- inp = """sample input"""
91
- expected_result = None
92
- aoc.assert_p1(inp, expected_result)
93
- aoc.submit_p1()
97
+ def part2(inp: str) -> str | int | None:
98
+ return None
94
99
 
95
- expected_result = None
96
- aoc.assert_p2(inp, expected_result)
97
- aoc.submit_p2()
98
100
  ```
99
101
 
100
- You write your solution in part1 and part2 functions.
102
+ Implement your solution in `part1` and `part2` functions and run
101
103
 
102
- `aoc.assert_p1(inp, expected_result)` will call your part1 function with inp and assert that the return matches expected_result.
104
+ ```bash
105
+ uv run adventofcode run
106
+ ```
103
107
 
104
- `aoc.submit_p1()` will fetch your puzzle input from the adventofcode.com, cache it locally and call `part1` with your puzzle input. If `part1` returns a value that isn't `None` that value will be submitted as your puzzle answer.
108
+ This will:
105
109
 
110
+ * Run your `part1` function with the inputs provided in the `part1_asserts` iterable and compare them with the expected values. If the function's return value doesn't match the expected answer, the command will stop. *Hint*: Each puzzle usually contains example input and an expected answer—these make for great asserts!
111
+ * If all the `part1_asserts` pass, `part1` will be called with your puzzle input fetched from adventofcode.com using your session cookie.
112
+ * If `part1` returns a non-None value for your puzzle input, that value will be submitted to adventofcode.com as your part 1 answer using your session cookie. All answer submissions are cached, so each unique answer will only be submitted once.
113
+ * If your answer was correct the same process repeats for `part2`.
106
114
 
107
115
  ### Set your session cookie
108
116
 
109
- Add the [adventofcode.com](https://adventofcode.com) session cookie value to your `.env` file or to your active session:
117
+ Add the [adventofcode.com](https://adventofcode.com) session cookie value to your `.env` file:
118
+
119
+ ```
120
+ # Set your Advent of Code session cookie below
121
+ # You can find it in your browser's developer tools after logging in to adventofcode.com.
122
+ # The name of the cookie is `session`.
123
+ AOC_SESSION="YOUR_SESSION_COOKIE_HERE"
124
+ AOC_YEAR=2025
125
+
126
+ ```
127
+
128
+ or to your environment variables:
110
129
 
111
130
  ```bash
112
131
  export AOC_SESSION="..."
113
132
  ```
114
133
 
115
134
  > [!NOTE]
116
- > Setting AOC_SESSION will allow you to get your personal puzzle output (`aoc.get_input()`) and submit your answers with `aoc.submit_p1()` and `aoc.submit_p2()`.
135
+ > You can find the session cookie by going to adventofcode.com in your browser. Make sure you are logged in, then open your browser's developer tools and navigate to Application → Storage → Cookies. Look for the cookie named `session` and copy its value.
117
136
 
118
137
  ### Benchmarks
119
138
 
120
139
  You can benchmark your solutions with
121
140
 
122
141
  ```shell
123
- adventofcode benchmark
142
+ uv run adventofcode benchmark
124
143
  ```
125
144
 
126
- This run each day and parse the timing results from the output. It will print the results in the console and in your README.
145
+ This will run each day's solution and parse the timing results from the output. The results will be printed to the console as well as added to your README.md.
127
146
 
128
147
  Example README:
129
148
 
@@ -162,7 +181,7 @@ Legend:
162
181
  * 🔴 > 1s
163
182
 
164
183
 
165
- ### Or build your workflow using the AoC class
184
+ ### Alternatively, you can build your own workflow using the lower level AoC class
166
185
 
167
186
  ```python
168
187
  from adventofcode import AoC
@@ -179,3 +198,8 @@ aoc.print_p2() # prints the second part of the puzzle
179
198
  ...
180
199
  aoc.submit_p2('part 2 answer') # submits the answer to the second part of the puzzle
181
200
  ```
201
+
202
+
203
+ ### Happy solving 🎄
204
+
205
+ Enjoy and have fun!
@@ -2,11 +2,10 @@
2
2
 
3
3
  Helper utilities for solving Advent of Code puzzles.
4
4
 
5
- * Project scaffolding with `adventofcode init`
6
- * Benchmark all the days with `adventofcode benchmark`
7
- * No copy-pasting puzzle inputs into files.
8
- * No need to use low-level file APIs to read your inputs.
9
- * Performance reports for example inputs and puzzle inputs.
5
+ * Project scaffolding with `uv run adventofcode init`
6
+ * Assert and submit your solutions with `uv run adventofcode run`
7
+ * Benchmark all your solutions with `uv run adventofcode benchmark`
8
+ * No copy-pasting puzzle inputs or loading inputs from files.
10
9
  * Submit the answer immediately when your code returns the result 🏅
11
10
 
12
11
  ## Usage
@@ -16,7 +15,7 @@ Helper utilities for solving Advent of Code puzzles.
16
15
  ```bash
17
16
  uv init
18
17
  uv add adventofcode
19
- adventofcode init
18
+ uv run adventofcode init
20
19
  ```
21
20
 
22
21
  This will generate the scripts for each day:
@@ -43,58 +42,78 @@ This will generate the scripts for each day:
43
42
  1 directory, 16 files
44
43
  ```
45
44
 
46
- All the py files look like this:
45
+ All the generated Python files look like this:
47
46
 
48
47
  ```python
49
- from adventofcode import AoC
48
+ """🎄 Solution for Day 1 of Advent of Code 2025 🎄
50
49
 
50
+ Usage:
51
51
 
52
- def part1(inp: str):
53
- return None
52
+ uv run adventofcode run 01.py
53
+ """
54
54
 
55
+ inp = """your input"""
56
+ part1_asserts = [
57
+ (inp, None),
58
+ ]
59
+ part2_asserts = [
60
+ (inp, None),
61
+ ]
55
62
 
56
- def part2(inp: str):
63
+
64
+ def part1(inp: str) -> str | int | None:
57
65
  return None
58
66
 
59
67
 
60
- aoc = AoC(part_1=part1, part_2=part2)
61
- inp = """sample input"""
62
- expected_result = None
63
- aoc.assert_p1(inp, expected_result)
64
- aoc.submit_p1()
68
+ def part2(inp: str) -> str | int | None:
69
+ return None
65
70
 
66
- expected_result = None
67
- aoc.assert_p2(inp, expected_result)
68
- aoc.submit_p2()
69
71
  ```
70
72
 
71
- You write your solution in part1 and part2 functions.
73
+ Implement your solution in `part1` and `part2` functions and run
72
74
 
73
- `aoc.assert_p1(inp, expected_result)` will call your part1 function with inp and assert that the return matches expected_result.
75
+ ```bash
76
+ uv run adventofcode run
77
+ ```
74
78
 
75
- `aoc.submit_p1()` will fetch your puzzle input from the adventofcode.com, cache it locally and call `part1` with your puzzle input. If `part1` returns a value that isn't `None` that value will be submitted as your puzzle answer.
79
+ This will:
76
80
 
81
+ * Run your `part1` function with the inputs provided in the `part1_asserts` iterable and compare them with the expected values. If the function's return value doesn't match the expected answer, the command will stop. *Hint*: Each puzzle usually contains example input and an expected answer—these make for great asserts!
82
+ * If all the `part1_asserts` pass, `part1` will be called with your puzzle input fetched from adventofcode.com using your session cookie.
83
+ * If `part1` returns a non-None value for your puzzle input, that value will be submitted to adventofcode.com as your part 1 answer using your session cookie. All answer submissions are cached, so each unique answer will only be submitted once.
84
+ * If your answer was correct the same process repeats for `part2`.
77
85
 
78
86
  ### Set your session cookie
79
87
 
80
- Add the [adventofcode.com](https://adventofcode.com) session cookie value to your `.env` file or to your active session:
88
+ Add the [adventofcode.com](https://adventofcode.com) session cookie value to your `.env` file:
89
+
90
+ ```
91
+ # Set your Advent of Code session cookie below
92
+ # You can find it in your browser's developer tools after logging in to adventofcode.com.
93
+ # The name of the cookie is `session`.
94
+ AOC_SESSION="YOUR_SESSION_COOKIE_HERE"
95
+ AOC_YEAR=2025
96
+
97
+ ```
98
+
99
+ or to your environment variables:
81
100
 
82
101
  ```bash
83
102
  export AOC_SESSION="..."
84
103
  ```
85
104
 
86
105
  > [!NOTE]
87
- > Setting AOC_SESSION will allow you to get your personal puzzle output (`aoc.get_input()`) and submit your answers with `aoc.submit_p1()` and `aoc.submit_p2()`.
106
+ > You can find the session cookie by going to adventofcode.com in your browser. Make sure you are logged in, then open your browser's developer tools and navigate to Application → Storage → Cookies. Look for the cookie named `session` and copy its value.
88
107
 
89
108
  ### Benchmarks
90
109
 
91
110
  You can benchmark your solutions with
92
111
 
93
112
  ```shell
94
- adventofcode benchmark
113
+ uv run adventofcode benchmark
95
114
  ```
96
115
 
97
- This run each day and parse the timing results from the output. It will print the results in the console and in your README.
116
+ This will run each day's solution and parse the timing results from the output. The results will be printed to the console as well as added to your README.md.
98
117
 
99
118
  Example README:
100
119
 
@@ -133,7 +152,7 @@ Legend:
133
152
  * 🔴 > 1s
134
153
 
135
154
 
136
- ### Or build your workflow using the AoC class
155
+ ### Alternatively, you can build your own workflow using the lower level AoC class
137
156
 
138
157
  ```python
139
158
  from adventofcode import AoC
@@ -150,3 +169,8 @@ aoc.print_p2() # prints the second part of the puzzle
150
169
  ...
151
170
  aoc.submit_p2('part 2 answer') # submits the answer to the second part of the puzzle
152
171
  ```
172
+
173
+
174
+ ### Happy solving 🎄
175
+
176
+ Enjoy and have fun!
@@ -0,0 +1 @@
1
+ __version__ = "25.4"
@@ -14,9 +14,11 @@ from bs4 import BeautifulSoup
14
14
  from dotenv import load_dotenv
15
15
  from rich.console import Console
16
16
 
17
+ from adventofcode.utils import PART_1_RETURN_STR, PART_2_RETURN_STR, format_time
18
+
17
19
  load_dotenv(Path(".env").absolute().as_posix())
18
20
  cache = percache.Cache(".cache", livesync=True)
19
- console = Console()
21
+ console = Console(log_path=False)
20
22
 
21
23
  AOC_URL = "https://adventofcode.com"
22
24
 
@@ -33,12 +35,23 @@ AOC_NOT_SET_MSG = (
33
35
  )
34
36
 
35
37
 
38
+ class PerfResult:
39
+ """Container to capture result from within a print_perf context."""
40
+
41
+ def __init__(self):
42
+ self.value = None
43
+
44
+
36
45
  @contextmanager
37
46
  def print_perf(typ=""):
38
47
  t0 = time.perf_counter()
39
- yield
48
+ result = PerfResult()
49
+ yield result
40
50
  diff = time.perf_counter() - t0
41
- console.log(f"{diff:.5f}s for {typ}")
51
+ if result.value is not None:
52
+ console.log(f"{format_time(diff)} to {typ}: {result.value}")
53
+ else:
54
+ console.log(f"{format_time(diff)} to {typ}")
42
55
 
43
56
 
44
57
  class AoC:
@@ -74,30 +87,46 @@ class AoC:
74
87
 
75
88
  def assert_p1(self, inp: str, expected: Any):
76
89
  res = None
77
- with print_perf("assert_p1"):
90
+ with print_perf("assert part1"):
78
91
  res = self.part_1(inp)
79
92
 
80
- assert res is not None, "Result of part_1 should not be None"
81
- assert res == expected, f"{res} != {expected}"
93
+ if res is None:
94
+ console.log(f"[red]part_1 returned [white]None[/white] for input:[/red]\n{inp[:100]}")
95
+ sys.exit(10)
96
+ if res != expected:
97
+ console.log(
98
+ f"[red]part_1 returned [white]{res}[/white] instead of expected [white]{expected}[/white]"
99
+ f" for input:[/red]\n{inp[:100]}"
100
+ )
101
+ sys.exit(11)
82
102
 
83
103
  def assert_p2(self, inp: str, expected: Any):
84
104
  res = None
85
- with print_perf("assert_p2"):
105
+ with print_perf("assert part2"):
86
106
  res = self.part_2(inp)
87
107
 
88
- assert res is not None, "Result of part_2 should not be None"
89
- assert res == expected, f"{res} != {expected}"
108
+ if res is None:
109
+ console.log(f"[red]part_2 returned [white]None[/white] for input:[/red]\n{inp[:100]}")
110
+ sys.exit(20)
111
+ if res != expected:
112
+ console.log(
113
+ f"[red]part_2 returned [white]{res}[/white] instead of expected [white]{expected}[/white]"
114
+ f" for input:[/red]\n{inp[:100]}"
115
+ )
116
+ sys.exit(21)
90
117
 
91
118
  def submit_p1(self, answer: Any | None = None):
92
- with print_perf("submit_p1"):
93
- answer = self.part_1(self.get_input())
94
-
119
+ inp = self.get_input()
120
+ with print_perf(PART_1_RETURN_STR) as perf:
121
+ answer = self.part_1(inp)
122
+ perf.value = answer
95
123
  submit(year=self.year, day=self.day, level=1, answer=answer)
96
124
 
97
125
  def submit_p2(self, answer: Any | None = None):
98
- with print_perf("submit_p2"):
99
- answer = self.part_2(self.get_input())
100
-
126
+ inp = self.get_input()
127
+ with print_perf(PART_2_RETURN_STR) as perf:
128
+ answer = self.part_2(inp)
129
+ perf.value = answer
101
130
  submit(year=self.year, day=self.day, level=2, answer=answer)
102
131
 
103
132
 
@@ -1,5 +1,6 @@
1
1
  import argparse
2
2
  import datetime
3
+ import importlib.util
3
4
  import os
4
5
  import re
5
6
  import subprocess
@@ -14,6 +15,9 @@ from rich.console import Console
14
15
  from rich.live import Live
15
16
  from rich.table import Table
16
17
 
18
+ from adventofcode import AoC
19
+ from adventofcode.utils import PART_1_RETURN_STR, PART_2_RETURN_STR, format_time
20
+
17
21
  load_dotenv(Path(".env").absolute().as_posix())
18
22
 
19
23
  est = datetime.timezone(datetime.timedelta(hours=-5))
@@ -21,9 +25,22 @@ today_est = datetime.datetime.now(tz=est).date()
21
25
 
22
26
  AOC_YEAR = int(os.getenv("AOC_YEAR", str(today_est.year)))
23
27
 
24
- console = Console()
28
+ console = Console(log_path=False)
25
29
  TEMPLATE = dedent('''\
26
- from adventofcode import AoC
30
+ """🎄 Solution for Day {day} of Advent of Code {year} 🎄
31
+
32
+ Usage:
33
+
34
+ uv run adventofcode run {day:02d}.py
35
+ """
36
+
37
+ inp = """your input"""
38
+ part1_asserts = [
39
+ (inp, None),
40
+ ]
41
+ part2_asserts = [
42
+ (inp, None),
43
+ ]
27
44
 
28
45
 
29
46
  def part1(inp: str) -> str | int | None:
@@ -32,21 +49,10 @@ TEMPLATE = dedent('''\
32
49
 
33
50
  def part2(inp: str) -> str | int | None:
34
51
  return None
35
-
36
-
37
- aoc = AoC(part_1=part1, part_2=part2)
38
- inp = """sample input"""
39
- expected_result = None
40
- aoc.assert_p1(inp, expected_result)
41
- aoc.submit_p1()
42
-
43
- expected_result = None
44
- aoc.assert_p2(inp, expected_result)
45
- aoc.submit_p2()
46
52
  ''')
47
53
 
48
54
 
49
- def generate_templates(year: int, output_dir: Path, num_days: int) -> None:
55
+ def init_templates(year: int, output_dir: Path, num_days: int) -> None:
50
56
  """Generate template files for the specified year."""
51
57
  output_dir.mkdir(parents=True, exist_ok=True)
52
58
 
@@ -60,7 +66,7 @@ def generate_templates(year: int, output_dir: Path, num_days: int) -> None:
60
66
  console.log(f"Skipping {filename} (already exists)")
61
67
  continue
62
68
 
63
- filepath.write_text(TEMPLATE)
69
+ filepath.write_text(TEMPLATE.format(day=day, year=year))
64
70
  console.log(f"Created {filename}")
65
71
 
66
72
  gitignore_path = output_dir / ".gitignore"
@@ -95,19 +101,23 @@ def parse_timing_output(output: str) -> tuple[float, float]:
95
101
  """Parse timing information from the AoC class output.
96
102
 
97
103
  The AoC class outputs lines like:
98
- - "0.00123s for submit_p1"
99
- - "0.00456s for submit_p2"
104
+ - "0.12ms to return part1 result: "
105
+ - "1.45s to return part2 result: "
100
106
  """
101
107
  part1_time = part2_time = 0.0
102
108
 
103
109
  for line in output.split("\n"):
104
- match = re.search(r"(\d+\.\d+)s for (?:submit_p1)", line)
110
+ match = re.search(r"(\d+\.\d+)m?s to " + PART_1_RETURN_STR, line)
105
111
  if match:
106
112
  part1_time = float(match.group(1))
113
+ if "ms" in line:
114
+ part1_time /= 1000.0
107
115
 
108
- match = re.search(r"(\d+\.\d+)s for (?:submit_p2)", line)
116
+ match = re.search(r"(\d+\.\d+)m?s to " + PART_2_RETURN_STR, line)
109
117
  if match:
110
118
  part2_time = float(match.group(1))
119
+ if "ms" in line:
120
+ part2_time /= 1000.0
111
121
 
112
122
  return part1_time, part2_time
113
123
 
@@ -144,9 +154,13 @@ def run_day(filepath: Path) -> DayResult:
144
154
 
145
155
  result = DayResult(day=filepath.stem)
146
156
 
157
+ if "adventofcode run" in filepath.read_text():
158
+ command = ["adventofcode", "run", str(filepath)]
159
+ else:
160
+ command = [sys.executable, str(filepath)]
147
161
  try:
148
162
  proc = subprocess.run( # noqa: S603
149
- [sys.executable, str(filepath)],
163
+ command,
150
164
  cwd=filepath.parent,
151
165
  capture_output=True,
152
166
  text=True,
@@ -189,14 +203,6 @@ def run_day(filepath: Path) -> DayResult:
189
203
  return result
190
204
 
191
205
 
192
- def format_time(seconds: float) -> str:
193
- if seconds <= 0.0:
194
- return "-"
195
- if seconds < 1:
196
- return f"{seconds * 1000:.1f}ms"
197
- return f"{seconds:.2f}s"
198
-
199
-
200
206
  def build_markdown_table(results: list[DayResult], total_time: float, total_part_1: float, total_part_2: float) -> str:
201
207
  """Generate a markdown table from benchmark results."""
202
208
  lines = [
@@ -296,7 +302,7 @@ def build_console_table(
296
302
  return table
297
303
 
298
304
 
299
- def run_benchmark(directory: Path) -> None:
305
+ def benchmark(directory: Path) -> None:
300
306
  console.log("[bold]Running benchmarks for Advent of Code[/bold]\n")
301
307
 
302
308
  # Find all day files
@@ -355,6 +361,37 @@ def run_benchmark(directory: Path) -> None:
355
361
  update_readme(readme_path, results_table)
356
362
 
357
363
 
364
+ def run(filepath: Path) -> None:
365
+ # Import the python module on path
366
+ if not filepath.exists():
367
+ console.log(f"[red]File {filepath} does not exist[/red]")
368
+ return
369
+
370
+ console.log(f"[bold]Running {filepath}[/bold]\n")
371
+ spec = importlib.util.spec_from_file_location(filepath.stem, filepath)
372
+ if not spec or not spec.loader:
373
+ console.log(f"[red]Could not load module from {filepath}[/red]")
374
+ return
375
+ module = importlib.util.module_from_spec(spec)
376
+ spec.loader.exec_module(module)
377
+
378
+ aoc = AoC(part_1=module.part1, part_2=module.part2, day=int(filepath.stem), year=AOC_YEAR)
379
+ if hasattr(module, "part1_asserts"):
380
+ for test_input, expected in module.part1_asserts:
381
+ aoc.assert_p1(test_input, expected)
382
+ else:
383
+ console.log("[yellow]No part 1 assertions found[/yellow]\n")
384
+
385
+ aoc.submit_p1()
386
+ if hasattr(module, "part2_asserts"):
387
+ for test_input, expected in module.part2_asserts:
388
+ aoc.assert_p2(test_input, expected)
389
+ else:
390
+ console.log("[yellow]No part 2 assertions found[/yellow]\n")
391
+
392
+ aoc.submit_p2()
393
+
394
+
358
395
  def main() -> None:
359
396
  """Main entry point for the CLI."""
360
397
  parser = argparse.ArgumentParser(
@@ -425,13 +462,32 @@ def main() -> None:
425
462
  help="Directory containing day files (default: current directory)",
426
463
  )
427
464
 
465
+ # Run Command
466
+ run_parser = subparsers.add_parser(
467
+ "run",
468
+ help="Run a specific day's solution",
469
+ description="Run the solution for a specific day and display the output.",
470
+ formatter_class=argparse.RawDescriptionHelpFormatter,
471
+ epilog=dedent("""\
472
+ Examples:
473
+ adventofcode run 01.py # Run day 1 solution in current directory
474
+ """),
475
+ )
476
+ run_parser.add_argument(
477
+ "filepath",
478
+ type=Path,
479
+ help="Path to the day file to run (e.g., 01.py)",
480
+ )
481
+
428
482
  args = parser.parse_args()
429
483
 
430
484
  match args.command:
431
485
  case "init":
432
- generate_templates(args.year, args.directory, 12 if args.year >= 2025 else 25)
486
+ init_templates(args.year, args.directory, 12 if args.year >= 2025 else 25)
433
487
  case "benchmark":
434
- run_benchmark(args.directory)
488
+ benchmark(args.directory)
489
+ case "run":
490
+ run(args.filepath)
435
491
  case _:
436
492
  parser.print_help()
437
493
 
@@ -0,0 +1,10 @@
1
+ PART_1_RETURN_STR = "return part1 result"
2
+ PART_2_RETURN_STR = "return part2 result"
3
+
4
+
5
+ def format_time(seconds: float) -> str:
6
+ if seconds <= 0.0:
7
+ return "-"
8
+ if seconds < 1:
9
+ return f"{seconds * 1000:.2f}ms"
10
+ return f"{seconds:.2f}s"
@@ -1 +0,0 @@
1
- __version__ = "25.2"
File without changes
File without changes
File without changes
File without changes