Skip to content

Commit 4d3079b

Browse files
committed
Bootstrap 2024
1 parent d41d8d1 commit 4d3079b

File tree

5 files changed

+162
-7
lines changed

5 files changed

+162
-7
lines changed

2024/README.md

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
Advent of Code 2024 walkthrough
2+
===============================
3+
4+
*Coming soon!*
5+
6+
7+
---
8+
9+
*Copyright © 2024 Marco Bonelli. This document is licensed under the [Creative Commons BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/) license.*
10+
11+
![License icon](https://licensebuttons.net/l/by-nc-sa/4.0/88x31.png)
12+
13+
14+
[top]: #advent-of-code-2023-walkthrough
15+
[d01]: #day-1---trebuchet
16+
[d02]: #day-2---cube-conundrum
17+
[d03]: #day-3---gear-ratios
18+
[d04]: #day-4---scratchcards
19+
[d05]: #day-5---if-you-give-a-seed-a-fertilizer
20+
[d06]: #day-6---wait-for-it
21+
[d07]: #day-7---camel-cards
22+
[d08]: #day-8---haunted-wasteland
23+
[d09]: #day-9---mirage-maintenance
24+
[d10]: #day-10---
25+
[d11]: #day-11---cosmic-expansion
26+
[d12]: #day-12---hot-springs
27+
[d13]: #day-13---point-of-incidence
28+
[d14]: #day-14---parabolic-reflector-dish
29+
[d15]: #day-15---lens-library
30+
[d16]: #day-16---the-floor-will-be-lava
31+
[d17]: #day-17---clumsy-crucible
32+
[d18]: #day-18---lavaduct-lagoon
33+
[d19]: #day-19---aplenty
34+
[d20]: #day-20---pulse-propagation
35+
[d21]: #day-21---
36+
[d22]: #day-22---
37+
[d24]: #day-24---
38+
[d25]: #day-25---
39+
40+
[d01-problem]: https://adventofcode.com/2023/day/1
41+
[d02-problem]: https://adventofcode.com/2023/day/2
42+
[d03-problem]: https://adventofcode.com/2023/day/3
43+
[d04-problem]: https://adventofcode.com/2023/day/4
44+
[d05-problem]: https://adventofcode.com/2023/day/5
45+
[d06-problem]: https://adventofcode.com/2023/day/6
46+
[d07-problem]: https://adventofcode.com/2023/day/7
47+
[d08-problem]: https://adventofcode.com/2023/day/8
48+
[d09-problem]: https://adventofcode.com/2023/day/9
49+
[d10-problem]: https://adventofcode.com/2023/day/10
50+
[d11-problem]: https://adventofcode.com/2023/day/11
51+
[d12-problem]: https://adventofcode.com/2023/day/12
52+
[d13-problem]: https://adventofcode.com/2023/day/13
53+
[d14-problem]: https://adventofcode.com/2023/day/14
54+
[d15-problem]: https://adventofcode.com/2023/day/15
55+
[d16-problem]: https://adventofcode.com/2023/day/16
56+
[d17-problem]: https://adventofcode.com/2023/day/17
57+
[d18-problem]: https://adventofcode.com/2023/day/18
58+
[d19-problem]: https://adventofcode.com/2023/day/19
59+
[d20-problem]: https://adventofcode.com/2023/day/20
60+
[d21-problem]: https://adventofcode.com/2023/day/21
61+
[d22-problem]: https://adventofcode.com/2023/day/22
62+
[d24-problem]: https://adventofcode.com/2023/day/24
63+
[d25-problem]: https://adventofcode.com/2023/day/25
64+
65+
[d01-solution]: solutions/day01.py
66+
[d02-solution]: solutions/day02.py
67+
[d03-solution]: solutions/day03.py
68+
[d04-solution]: solutions/day04.py
69+
[d05-solution]: solutions/day05.py
70+
[d06-solution]: solutions/day06.py
71+
[d07-solution]: solutions/day07.py
72+
[d08-solution]: solutions/day08.py
73+
[d09-solution]: solutions/day09.py
74+
[d10-solution]: solutions/day10.py
75+
[d11-solution]: solutions/day11.py
76+
[d12-solution]: solutions/day12.py
77+
[d13-solution]: solutions/day13.py
78+
[d14-solution]: solutions/day14.py
79+
[d15-solution]: solutions/day15.py
80+
[d16-solution]: solutions/day16.py
81+
[d17-solution]: solutions/day17.py
82+
[d18-solution]: solutions/day18.py
83+
[d19-solution]: solutions/day19.py
84+
[d20-solution]: solutions/day20.py
85+
[d21-solution]: solutions/day21.py
86+
[d22-solution]: solutions/day22.py
87+
[d24-solution]: solutions/day24.py
88+
[d25-solution]: solutions/day25.py

2024/original_solutions/day01.py

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env python3
2+
3+
from utils.all import *
4+
5+
# advent.setup(2024, )
6+
DEBUG = 'debug' in map(str.lower, sys.argv)
7+
fin = advent.get_input() if not DEBUG else io.StringIO('''\
8+
9+
''')
10+
eprint(*fin, sep='', end='----- end of input -----\n\n'); fin.seek(0, 0)
11+
12+
try: data = fin.read(); fin.seek(0, 0)
13+
except: pass
14+
try: ints = extract_ints(data)
15+
except: pass
16+
try: intmat = read_int_matrix(fin); fin.seek(0, 0)
17+
except: pass
18+
try: lines = read_lines(fin); fin.seek(0, 0)
19+
except: pass
20+
try: grid = read_char_matrix(fin); fin.seek(0, 0)
21+
except: pass
22+
try: intgrid = read_digit_matrix(fin); fin.seek(0, 0)
23+
except: pass
24+
try: g = graph_from_grid(grid, find='QWERTYUIOPASDFGHJKLZXCVBNM', avoid='#', coords=False, get_neighbors=neighbors4)
25+
except: pass
26+
timer_start()
27+
28+
ans1 = ans2 = 0
29+
# g = defaultdict(list)
30+
31+
# for r, row in enumerate(grid):
32+
# for c, char in enumerate(row):
33+
# pass
34+
35+
# for r, row in enumerate(intgrid):
36+
# for c, num in enumerate(row):
37+
# pass
38+
39+
# for line in lines:
40+
41+
42+
43+
44+
45+
46+
advent.print_and_submit(1, ans1)
47+
# advent.print_answer(1, ans1)
48+
49+
50+
51+
52+
53+
54+
advent.print_and_submit(2, ans2)
55+
# advent.print_answer(2, ans2)
56+
57+
58+
# - Can you memoize some state for which the solution will always be the same?
59+
# - Can you batch operations together instead of doing them singularly?
60+
# - Too many points? Coordinate compression? Shoelace formula?
61+
# - Can you go blind with Z3 (or GCC+IDA+Z3) instead of reverse engineering?

2024/original_solutions/utils

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

2024/solutions/utils

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

README.md

+11-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ Personal repository of [Advent of Code](#about-advent-of-code) solutions.
66
### Quick links
77

88
- **[How to run my solutions on your inputs][how-to-run]**
9-
- **AoC 2023: [walkthrough][2023-wal], [clean][2023-sol] / [original][2023-ori] solutions**
9+
- **AoC 2024: [walkthrough][2024-wal], [clean][2024-sol] / [original][2024-ori] solutions**
10+
- AoC 2023: [walkthrough][2023-wal], [clean][2023-sol] / [original][2023-ori] solutions
1011
- AoC 2022: [walkthrough][2022-wal], [clean][2022-sol] / [original][2022-ori] solutions, complete [calendar][2022-cal] and [leaderboard][2022-lea]
1112
- AoC 2021: [walkthrough][2021-wal], [clean][2021-sol] / [original][2021-ori] solutions, complete [calendar][2021-cal] and [leaderboard][2021-lea]
1213
- AoC 2020: [walkthrough][2020-wal], [clean][2020-sol] / [original][2020-ori] solutions, complete [calendar][2020-cal] and [leaderboard][2020-lea]
@@ -71,22 +72,22 @@ rewrite them more cleanly right away.</sup>
7172
How to run my solutions
7273
-----------------------
7374

74-
Provide your input from standard input:
75+
You can provide your input from standard input:
7576

7677
```bash
7778
2022/solutions/day01.py
7879
# Paste input here and type CTRL+D when done...
7980
```
8081

81-
Save your input to file and pass its path as argument:
82+
You can save your input to file and pass its path as argument:
8283

8384
```bash
8485
2022/solutions/day01.py path/to/your/input.txt
8586
```
8687

87-
Directly download your input from the AoC website (you will need to extract your
88-
session cookie from your browser and replace `VALUE` below with
89-
the real value, please *only do this if you understand what you are doing*):
88+
Or you can directly download your input from the AoC website. You will need to
89+
extract your session cookie from your browser and replace `VALUE` below with the
90+
real value, please *only do this if you understand what you are doing*.
9091

9192
```bash
9293
curl -s --cookie 'session=VALUE' 'https://adventofcode.com/2022/day/1/input' | 2022/solutions/day01.py
@@ -115,8 +116,11 @@ license, which you can find in the file
115116

116117
---
117118

118-
*Copyright &copy; 2018-2023 Marco Bonelli.*
119+
*Copyright &copy; 2018-2024 Marco Bonelli.*
119120

121+
[2024-wal]: 2024/README.md
122+
[2024-sol]: 2024/solutions
123+
[2024-ori]: 2024/original_solutions
120124

121125
[2023-wal]: 2023/README.md
122126
[2023-sol]: 2023/solutions

0 commit comments

Comments
 (0)