fraocme 1.0.0b1__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.
Files changed (55) hide show
  1. fraocme-1.0.0b1/LICENSE +21 -0
  2. fraocme-1.0.0b1/PKG-INFO +197 -0
  3. fraocme-1.0.0b1/README.md +170 -0
  4. fraocme-1.0.0b1/fraocme/__init__.py +19 -0
  5. fraocme-1.0.0b1/fraocme/cli.py +249 -0
  6. fraocme-1.0.0b1/fraocme/common/__init__.py +63 -0
  7. fraocme-1.0.0b1/fraocme/common/parser.py +233 -0
  8. fraocme-1.0.0b1/fraocme/common/printer.py +267 -0
  9. fraocme-1.0.0b1/fraocme/common/types.py +9 -0
  10. fraocme-1.0.0b1/fraocme/common/utils.py +572 -0
  11. fraocme-1.0.0b1/fraocme/core/__init__.py +7 -0
  12. fraocme-1.0.0b1/fraocme/core/runner.py +119 -0
  13. fraocme-1.0.0b1/fraocme/core/solver.py +149 -0
  14. fraocme-1.0.0b1/fraocme/examples/days/day_00/solution.py +47 -0
  15. fraocme-1.0.0b1/fraocme/examples/days/day_01/solution.py +110 -0
  16. fraocme-1.0.0b1/fraocme/examples/days/day_02/solution.py +124 -0
  17. fraocme-1.0.0b1/fraocme/examples/days/day_03/solution.py +135 -0
  18. fraocme-1.0.0b1/fraocme/examples/days/day_04/solution.py +135 -0
  19. fraocme-1.0.0b1/fraocme/examples/days/day_101/solution.py +170 -0
  20. fraocme-1.0.0b1/fraocme/examples/days/day_102/solution.py +112 -0
  21. fraocme-1.0.0b1/fraocme/examples/days/day_103/solution.py +139 -0
  22. fraocme-1.0.0b1/fraocme/examples/days/day_104/solution.py +133 -0
  23. fraocme-1.0.0b1/fraocme/examples/days/day_105/solution.py +104 -0
  24. fraocme-1.0.0b1/fraocme/grid/__init__.py +77 -0
  25. fraocme-1.0.0b1/fraocme/grid/core.py +384 -0
  26. fraocme-1.0.0b1/fraocme/grid/directions.py +100 -0
  27. fraocme-1.0.0b1/fraocme/grid/parser.py +130 -0
  28. fraocme-1.0.0b1/fraocme/grid/pathfinding.py +216 -0
  29. fraocme-1.0.0b1/fraocme/grid/printer.py +940 -0
  30. fraocme-1.0.0b1/fraocme/grid/regions.py +181 -0
  31. fraocme-1.0.0b1/fraocme/grid/transformations.py +102 -0
  32. fraocme-1.0.0b1/fraocme/grid/types.py +5 -0
  33. fraocme-1.0.0b1/fraocme/profiling/__init__.py +11 -0
  34. fraocme-1.0.0b1/fraocme/profiling/printer.py +218 -0
  35. fraocme-1.0.0b1/fraocme/profiling/stats.py +84 -0
  36. fraocme-1.0.0b1/fraocme/profiling/timer.py +102 -0
  37. fraocme-1.0.0b1/fraocme/test_runner.py +17 -0
  38. fraocme-1.0.0b1/fraocme/ui/__init__.py +9 -0
  39. fraocme-1.0.0b1/fraocme/ui/colors.py +140 -0
  40. fraocme-1.0.0b1/fraocme/ui/printer.py +79 -0
  41. fraocme-1.0.0b1/fraocme.egg-info/PKG-INFO +197 -0
  42. fraocme-1.0.0b1/fraocme.egg-info/SOURCES.txt +53 -0
  43. fraocme-1.0.0b1/fraocme.egg-info/dependency_links.txt +1 -0
  44. fraocme-1.0.0b1/fraocme.egg-info/entry_points.txt +3 -0
  45. fraocme-1.0.0b1/fraocme.egg-info/requires.txt +5 -0
  46. fraocme-1.0.0b1/fraocme.egg-info/top_level.txt +1 -0
  47. fraocme-1.0.0b1/pyproject.toml +71 -0
  48. fraocme-1.0.0b1/setup.cfg +4 -0
  49. fraocme-1.0.0b1/tests/test_cli.py +835 -0
  50. fraocme-1.0.0b1/tests/test_common.py +390 -0
  51. fraocme-1.0.0b1/tests/test_core.py +638 -0
  52. fraocme-1.0.0b1/tests/test_grid.py +228 -0
  53. fraocme-1.0.0b1/tests/test_grid_advanced.py +631 -0
  54. fraocme-1.0.0b1/tests/test_profiling.py +511 -0
  55. fraocme-1.0.0b1/tests/test_ui.py +294 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 MalikAza
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,197 @@
1
+ Metadata-Version: 2.4
2
+ Name: fraocme
3
+ Version: 1.0.0b1
4
+ Summary: A compact, testable framework for writing Advent of Code solutions in Python
5
+ Author-email: MalikAza <dakota.froissart@powaza.fr>, Weyrd <pierre.pinateau@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/MalikAza/fraocme
8
+ Project-URL: Repository, https://github.com/MalikAza/fraocme.git
9
+ Project-URL: Issues, https://github.com/MalikAza/fraocme/issues
10
+ Project-URL: Documentation, https://github.com/MalikAza/fraocme#readme
11
+ Keywords: advent-of-code,aoc,framework,python,testing
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
+ Classifier: Topic :: Games/Entertainment :: Puzzle Games
19
+ Requires-Python: >=3.13
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Provides-Extra: dev
23
+ Requires-Dist: pytest>=7.0; extra == "dev"
24
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
25
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
26
+ Dynamic: license-file
27
+
28
+ # 🎄 Fraocme
29
+
30
+ [![Tests](https://github.com/MalikAza/fraocme/actions/workflows/test.yml/badge.svg)](https://github.com/MalikAza/fraocme/actions/workflows/test.yml)
31
+ [![Lint](https://github.com/MalikAza/fraocme/actions/workflows/lint.yml/badge.svg)](https://github.com/MalikAza/fraocme/actions/workflows/lint.yml)
32
+ [![Format](https://github.com/MalikAza/fraocme/actions/workflows/format.yml/badge.svg)](https://github.com/MalikAza/fraocme/actions/workflows/format.yml)
33
+ [![codecov](https://codecov.io/gh/MalikAza/fraocme/branch/main/graph/badge.svg)](https://codecov.io/gh/MalikAza/fraocme)
34
+
35
+ > *Your cozy companion for solving Advent of Code puzzles in Python* ☕✨
36
+
37
+ Fraocme is a lightweight framework that makes tackling those December coding challenges a breeze. Think clean project structure, helpful debugging tools, and automated timing—all wrapped up like a present under the tree.
38
+
39
+ **What's Inside:**
40
+ - 🎁 Simple project scaffolding
41
+ - 🐛 Smart debug utilities
42
+ - ⏱️ Performance tracking & stats
43
+ - 🎨 Pretty output formatting
44
+
45
+ ## 🎅 Installation
46
+
47
+ ```bash
48
+ pip install -e .
49
+ ```
50
+
51
+ ## 🚀 Quick Start
52
+
53
+ Get unwrapping your first puzzle in seconds:
54
+
55
+ 1. **Create** a new day solution:
56
+ ```bash
57
+ fraocme create 1
58
+ ```
59
+
60
+ 2. **Edit** `days/day_01/solution.py` and implement your `parse`, `part1`, and `part2` methods.
61
+
62
+ 3. **Add** your puzzle input to `days/day_01/input.txt`.
63
+
64
+ 4. **Run** it:
65
+ ```bash
66
+ fraocme run 1
67
+ ```
68
+
69
+ That's it! 🎉
70
+
71
+ ## 📝 Example Solution
72
+
73
+ Here's what a typical solution looks like:
74
+
75
+ ```python
76
+ from fraocme import Solver
77
+ from fraocme.common.parser import char_lines
78
+
79
+ class Day1(Solver):
80
+ def parse(self, raw: str) -> list[list[int]]:
81
+ # Parse each line into individual digits
82
+ return char_lines(raw)
83
+
84
+ def part1(self, data: list[list[int]]) -> int:
85
+ # Use debug helpers during development
86
+ self.debug("Processing", len(data), "lines")
87
+ return sum(max(line) for line in data)
88
+
89
+ def part2(self, data: list[list[int]]) -> int:
90
+ return sum(sum(line) for line in data)
91
+ ```
92
+
93
+ **Pro Tips:**
94
+ - 🐛 Pass callables to `self.debug(lambda: expensive_function())` to avoid computing debug output when not needed
95
+ - 📋 The base `Solver` automatically handles input copying, so parts don't interfere with each other
96
+
97
+ ## 🎮 Command Line Interface
98
+
99
+ ### Creating Solutions
100
+ ```bash
101
+ fraocme create <day> # Creates days/day_XX/ with solution.py and input.txt
102
+ # Day must be between 1 and 25 (for those calendar dates!)
103
+ ```
104
+
105
+ ### Running Solutions
106
+ ```bash
107
+ fraocme run <day> # Run a specific day
108
+ fraocme run 1 -p 1 # Run only part 1
109
+ fraocme run 1 --debug # Run with debug output enabled
110
+ fraocme run 1 --no-traceback # Hide tracebacks on errors (cleaner output)
111
+ fraocme run --all # Run all days (marathon mode! 🏃)
112
+ ```
113
+
114
+ ### Viewing Statistics
115
+ ```bash
116
+ fraocme stats # Show all stats
117
+ fraocme stats 1 # Show stats for day 1
118
+ ```
119
+ ## 🎁 Parsers & Utilities
120
+
121
+ Common parsing patterns are built right in:
122
+
123
+ ```python
124
+ from fraocme.common.parser import (
125
+ lines, # Split into lines
126
+ ints, # Parse integers (one per line)
127
+ digits, # Parse digits into lists [[1,2,3], [4,5,6]]
128
+ sections, # Split by blank lines
129
+ ```
130
+ ## 🐛 Debugging
131
+
132
+ Enable debug output with the `--debug` flag:
133
+
134
+ ```python
135
+ self.debug("Current value:", x)
136
+ self.debug(lambda: expensive_visualization(grid)) # Only computed when --debug is used
137
+ ```
138
+
139
+ **Available Debug Helpers:**
140
+ ```python
141
+ from fraocme.common.printer import (
142
+ print_dict_row, # Pretty-print dictionaries
143
+ print_ranges, # Show range summaries
144
+ ```
145
+ ## 🧪 Testing
146
+
147
+ ```bash
148
+ python -m unittest discover -v tests/
149
+ # or with uv:
150
+ uv run test
151
+ ```
152
+
153
+ See [tests/README.md](tests/README.md) for more details on test organization.
154
+
155
+ ## 🎄 Happy Coding!
156
+
157
+ May your solutions be elegant, your bugs be few, and your stars be plentiful! ⭐⭐
158
+
159
+ ---
160
+
161
+ *Built with ❤️ for Advent of Code enthusiasts*
162
+ There is also a `Grid` class and helpers for points/directions used in grid-style puzzles.
163
+
164
+ **Debugging**
165
+
166
+ Call `self.debug(...)` inside your `Solver` methods. If you need to avoid evaluating
167
+ expressions unless debug is enabled, pass a callable:
168
+
169
+ ```python
170
+ self.debug(lambda: expensive_debug_print(data))
171
+ ```
172
+
173
+ **Stats & Timing**
174
+
175
+ Run times are collected by the framework and can be saved to `stats.json`. Some helper
176
+ decorators (e.g. `@timed`, `@benchmark`) are available under `fraocme.profiling`.
177
+
178
+ **Code Quality**
179
+
180
+ The project uses [Ruff](https://github.com/astral-sh/ruff) for linting and formatting.
181
+
182
+ ```bash
183
+ # Check for linting issues
184
+ uv run ruff check .
185
+
186
+ # Format code
187
+ uv run ruff format .
188
+
189
+ # Fix fixable issues
190
+ uv run ruff check --fix .
191
+ ```
192
+
193
+ **Tests**
194
+
195
+ See [tests/README.md](tests/README.md) for test organization and running tests.
196
+
197
+ ---
@@ -0,0 +1,170 @@
1
+ # 🎄 Fraocme
2
+
3
+ [![Tests](https://github.com/MalikAza/fraocme/actions/workflows/test.yml/badge.svg)](https://github.com/MalikAza/fraocme/actions/workflows/test.yml)
4
+ [![Lint](https://github.com/MalikAza/fraocme/actions/workflows/lint.yml/badge.svg)](https://github.com/MalikAza/fraocme/actions/workflows/lint.yml)
5
+ [![Format](https://github.com/MalikAza/fraocme/actions/workflows/format.yml/badge.svg)](https://github.com/MalikAza/fraocme/actions/workflows/format.yml)
6
+ [![codecov](https://codecov.io/gh/MalikAza/fraocme/branch/main/graph/badge.svg)](https://codecov.io/gh/MalikAza/fraocme)
7
+
8
+ > *Your cozy companion for solving Advent of Code puzzles in Python* ☕✨
9
+
10
+ Fraocme is a lightweight framework that makes tackling those December coding challenges a breeze. Think clean project structure, helpful debugging tools, and automated timing—all wrapped up like a present under the tree.
11
+
12
+ **What's Inside:**
13
+ - 🎁 Simple project scaffolding
14
+ - 🐛 Smart debug utilities
15
+ - ⏱️ Performance tracking & stats
16
+ - 🎨 Pretty output formatting
17
+
18
+ ## 🎅 Installation
19
+
20
+ ```bash
21
+ pip install -e .
22
+ ```
23
+
24
+ ## 🚀 Quick Start
25
+
26
+ Get unwrapping your first puzzle in seconds:
27
+
28
+ 1. **Create** a new day solution:
29
+ ```bash
30
+ fraocme create 1
31
+ ```
32
+
33
+ 2. **Edit** `days/day_01/solution.py` and implement your `parse`, `part1`, and `part2` methods.
34
+
35
+ 3. **Add** your puzzle input to `days/day_01/input.txt`.
36
+
37
+ 4. **Run** it:
38
+ ```bash
39
+ fraocme run 1
40
+ ```
41
+
42
+ That's it! 🎉
43
+
44
+ ## 📝 Example Solution
45
+
46
+ Here's what a typical solution looks like:
47
+
48
+ ```python
49
+ from fraocme import Solver
50
+ from fraocme.common.parser import char_lines
51
+
52
+ class Day1(Solver):
53
+ def parse(self, raw: str) -> list[list[int]]:
54
+ # Parse each line into individual digits
55
+ return char_lines(raw)
56
+
57
+ def part1(self, data: list[list[int]]) -> int:
58
+ # Use debug helpers during development
59
+ self.debug("Processing", len(data), "lines")
60
+ return sum(max(line) for line in data)
61
+
62
+ def part2(self, data: list[list[int]]) -> int:
63
+ return sum(sum(line) for line in data)
64
+ ```
65
+
66
+ **Pro Tips:**
67
+ - 🐛 Pass callables to `self.debug(lambda: expensive_function())` to avoid computing debug output when not needed
68
+ - 📋 The base `Solver` automatically handles input copying, so parts don't interfere with each other
69
+
70
+ ## 🎮 Command Line Interface
71
+
72
+ ### Creating Solutions
73
+ ```bash
74
+ fraocme create <day> # Creates days/day_XX/ with solution.py and input.txt
75
+ # Day must be between 1 and 25 (for those calendar dates!)
76
+ ```
77
+
78
+ ### Running Solutions
79
+ ```bash
80
+ fraocme run <day> # Run a specific day
81
+ fraocme run 1 -p 1 # Run only part 1
82
+ fraocme run 1 --debug # Run with debug output enabled
83
+ fraocme run 1 --no-traceback # Hide tracebacks on errors (cleaner output)
84
+ fraocme run --all # Run all days (marathon mode! 🏃)
85
+ ```
86
+
87
+ ### Viewing Statistics
88
+ ```bash
89
+ fraocme stats # Show all stats
90
+ fraocme stats 1 # Show stats for day 1
91
+ ```
92
+ ## 🎁 Parsers & Utilities
93
+
94
+ Common parsing patterns are built right in:
95
+
96
+ ```python
97
+ from fraocme.common.parser import (
98
+ lines, # Split into lines
99
+ ints, # Parse integers (one per line)
100
+ digits, # Parse digits into lists [[1,2,3], [4,5,6]]
101
+ sections, # Split by blank lines
102
+ ```
103
+ ## 🐛 Debugging
104
+
105
+ Enable debug output with the `--debug` flag:
106
+
107
+ ```python
108
+ self.debug("Current value:", x)
109
+ self.debug(lambda: expensive_visualization(grid)) # Only computed when --debug is used
110
+ ```
111
+
112
+ **Available Debug Helpers:**
113
+ ```python
114
+ from fraocme.common.printer import (
115
+ print_dict_row, # Pretty-print dictionaries
116
+ print_ranges, # Show range summaries
117
+ ```
118
+ ## 🧪 Testing
119
+
120
+ ```bash
121
+ python -m unittest discover -v tests/
122
+ # or with uv:
123
+ uv run test
124
+ ```
125
+
126
+ See [tests/README.md](tests/README.md) for more details on test organization.
127
+
128
+ ## 🎄 Happy Coding!
129
+
130
+ May your solutions be elegant, your bugs be few, and your stars be plentiful! ⭐⭐
131
+
132
+ ---
133
+
134
+ *Built with ❤️ for Advent of Code enthusiasts*
135
+ There is also a `Grid` class and helpers for points/directions used in grid-style puzzles.
136
+
137
+ **Debugging**
138
+
139
+ Call `self.debug(...)` inside your `Solver` methods. If you need to avoid evaluating
140
+ expressions unless debug is enabled, pass a callable:
141
+
142
+ ```python
143
+ self.debug(lambda: expensive_debug_print(data))
144
+ ```
145
+
146
+ **Stats & Timing**
147
+
148
+ Run times are collected by the framework and can be saved to `stats.json`. Some helper
149
+ decorators (e.g. `@timed`, `@benchmark`) are available under `fraocme.profiling`.
150
+
151
+ **Code Quality**
152
+
153
+ The project uses [Ruff](https://github.com/astral-sh/ruff) for linting and formatting.
154
+
155
+ ```bash
156
+ # Check for linting issues
157
+ uv run ruff check .
158
+
159
+ # Format code
160
+ uv run ruff format .
161
+
162
+ # Fix fixable issues
163
+ uv run ruff check --fix .
164
+ ```
165
+
166
+ **Tests**
167
+
168
+ See [tests/README.md](tests/README.md) for test organization and running tests.
169
+
170
+ ---
@@ -0,0 +1,19 @@
1
+ from .core import Runner, Solver
2
+ from .profiling import Stats, Timer
3
+ from .ui import (
4
+ Colors,
5
+ c,
6
+ print_header,
7
+ print_section,
8
+ )
9
+
10
+ __all__ = [
11
+ "Runner",
12
+ "Solver",
13
+ "Stats",
14
+ "Timer",
15
+ "Colors",
16
+ "c",
17
+ "print_header",
18
+ "print_section",
19
+ ]
@@ -0,0 +1,249 @@
1
+ import argparse
2
+ import sys
3
+
4
+ from fraocme.ui.printer import print_header
5
+
6
+ from .core.runner import Runner
7
+ from .profiling.stats import Stats
8
+ from .ui.colors import c
9
+
10
+
11
+ def main():
12
+ parser = argparse.ArgumentParser(
13
+ prog="fraocme", description="Advent of Code framework"
14
+ )
15
+
16
+ subparsers = parser.add_subparsers(dest="command", help="Commands")
17
+
18
+ # ─────────────────────────────────────────────────────────
19
+ # run command
20
+ # ─────────────────────────────────────────────────────────
21
+
22
+ run_parser = subparsers.add_parser("run", help="Run solution(s)")
23
+ run_parser.add_argument(
24
+ "day", type=int, nargs="?", default=None, help="Day number to run"
25
+ )
26
+ run_parser.add_argument(
27
+ "-p",
28
+ "--part",
29
+ type=int,
30
+ choices=[1, 2],
31
+ default=None,
32
+ help="Run only specific part",
33
+ )
34
+ run_parser.add_argument("-a", "--all", action="store_true", help="Run all days")
35
+ run_parser.add_argument(
36
+ "-d", "--debug", action="store_true", help="Enable debug output"
37
+ )
38
+ run_parser.add_argument(
39
+ "--example",
40
+ action="store_true",
41
+ help="Run with example input instead of main input",
42
+ )
43
+ run_parser.add_argument(
44
+ "--no-traceback", action="store_true", help="Don't show traceback on errors"
45
+ )
46
+ run_parser.add_argument("--no-stats", action="store_true", help="Don't save stats")
47
+
48
+ # ─────────────────────────────────────────────────────────
49
+ # stats command
50
+ # ─────────────────────────────────────────────────────────
51
+
52
+ stats_parser = subparsers.add_parser("stats", help="Show statistics")
53
+ stats_parser.add_argument(
54
+ "day", type=int, nargs="?", default=None, help="Day number (omit for all days)"
55
+ )
56
+ stats_parser.add_argument(
57
+ "--best", action="store_true", help="Show only best times"
58
+ )
59
+ stats_parser.add_argument(
60
+ "--reset", action="store_true", help="Reset stats for a day or all days"
61
+ )
62
+ stats_parser.add_argument(
63
+ "--all", action="store_true", help="Apply reset to all days"
64
+ )
65
+
66
+ # ─────────────────────────────────────────────────────────
67
+ # create command
68
+ # ─────────────────────────────────────────────────────────
69
+
70
+ create_parser = subparsers.add_parser(
71
+ "create", help="Create a new day solution folder and files"
72
+ )
73
+ create_parser.add_argument("day", type=int, help="Day number to create")
74
+
75
+ # ─────────────────────────────────────────────────────────
76
+ # Parse and dispatch
77
+ # ─────────────────────────────────────────────────────────
78
+
79
+ args = parser.parse_args()
80
+
81
+ if args.command is None:
82
+ parser.print_help()
83
+ sys.exit(0)
84
+
85
+ if args.command == "run":
86
+ cmd_run(args)
87
+ elif args.command == "stats":
88
+ cmd_stats(args)
89
+ elif args.command == "create":
90
+ cmd_create(args)
91
+
92
+
93
+ # ─────────────────────────────────────────────────────────
94
+ # Command handlers
95
+ # ─────────────────────────────────────────────────────────
96
+
97
+
98
+ def cmd_run(args):
99
+ """Handle run command."""
100
+ runner = Runner()
101
+ stats = Stats()
102
+
103
+ parts = [args.part] if args.part else [1, 2]
104
+
105
+ # Run all days
106
+ if args.all:
107
+ results = runner.run_all(
108
+ parts=parts,
109
+ debug=args.debug,
110
+ show_traceback=not args.no_traceback,
111
+ use_example=args.example,
112
+ )
113
+
114
+ if not args.no_stats and not args.example:
115
+ for day, day_results in results.items():
116
+ stats.update(day, day_results)
117
+ stats.save()
118
+ return
119
+
120
+ # Run specific day
121
+ if args.day is None:
122
+ print(c.error("Error: Specify a day number or use --all"))
123
+ sys.exit(1)
124
+
125
+ if not runner.day_exists(args.day):
126
+ print(
127
+ c.error("Error: Day ")
128
+ + c.bold(c.green(str(args.day)))
129
+ + c.error(" not found")
130
+ )
131
+ sys.exit(1)
132
+
133
+ results = runner.run_day(
134
+ args.day,
135
+ parts=parts,
136
+ debug=args.debug,
137
+ show_traceback=not args.no_traceback,
138
+ use_example=args.example,
139
+ )
140
+
141
+ # Prevent stats update if --example is used
142
+ if not args.no_stats and not args.example:
143
+ stats.update(args.day, results)
144
+ stats.save()
145
+
146
+
147
+ def cmd_stats(args):
148
+ """Handle stats command."""
149
+ print_header("Profiling Statistics")
150
+ stats = Stats()
151
+ from fraocme.profiling.printer import print_stats_day, print_stats_summary_table
152
+
153
+ if args.reset:
154
+ if args.all:
155
+ stats.reset_all()
156
+ print(c.success("✓ All stats reset."))
157
+ elif args.day is not None:
158
+ stats.reset_day(args.day)
159
+ print(c.success(f"✓ Stats for day {args.day} reset."))
160
+ else:
161
+ print(c.error("Specify a day to reset or use --all."))
162
+ return
163
+ if args.day is not None:
164
+ data = stats.get_day(args.day)
165
+ print_stats_day(args.day, data, best_only=args.best)
166
+ else:
167
+ data = stats.get_all()
168
+ if args.best:
169
+ print_stats_summary_table(data)
170
+ else:
171
+ days = sorted(data.keys(), key=lambda x: int(x.split("_")[1]))
172
+ for day_key in days:
173
+ day_num = int(day_key.split("_")[1])
174
+ print_stats_day(day_num, data[day_key], best_only=False)
175
+
176
+
177
+ def cmd_create(args):
178
+ """Handle create command."""
179
+ from pathlib import Path
180
+
181
+ day_num = args.day
182
+
183
+ # Validate day number
184
+ if day_num < 1 or day_num > 25:
185
+ print(
186
+ c.error("Error: Day number must be between 1 and 25, got ")
187
+ + c.bold(str(day_num))
188
+ )
189
+ sys.exit(1)
190
+
191
+ day_dir = Path.cwd() / "days" / f"day_{day_num:02d}"
192
+
193
+ # Check if day already exists
194
+ if day_dir.exists():
195
+ print(c.warning("Warning: ") + f"Day {day_num} already exists at {day_dir}")
196
+ return
197
+
198
+ # Create directory
199
+ day_dir.mkdir(parents=True, exist_ok=True)
200
+
201
+ # Create input.txt
202
+ input_file = day_dir / "input.txt"
203
+ input_file.write_text("")
204
+
205
+ # Create example_input.txt
206
+ example_input_file = day_dir / "example_input.txt"
207
+ example_input_file.write_text("")
208
+
209
+ # Create solution.py template
210
+ day_class_name = f"Day{day_num}"
211
+ solution_template = f'''from fraocme import Solver
212
+
213
+
214
+ class {day_class_name}(Solver):
215
+ def __init__(self, day: int = {day_num}, **kwargs):
216
+ super().__init__(day=day, **kwargs)
217
+
218
+ def parse(self, raw: str):
219
+ """Parse the input data."""
220
+ return raw.strip().split("\\n")
221
+
222
+ def part1(self, data):
223
+ """Solve part 1."""
224
+ return None
225
+
226
+ def part2(self, data):
227
+ """Solve part 2."""
228
+ return None
229
+ '''
230
+
231
+ solution_file = day_dir / "solution.py"
232
+ solution_file.write_text(solution_template)
233
+
234
+ print(
235
+ c.success("✓ Created day ")
236
+ + c.bold(c.cyan(str(day_num)))
237
+ + c.success(" at ")
238
+ + c.bold(str(day_dir))
239
+ )
240
+ print(
241
+ c.muted("Created:")
242
+ + f" {input_file.name}"
243
+ + f", {example_input_file.name}"
244
+ + f", {solution_file.name}"
245
+ )
246
+
247
+
248
+ if __name__ == "__main__":
249
+ main()