Commit Graph

34 Commits

Author SHA1 Message Date
Érico Nogueira 8bba157759 Add Advent 2021 - day 25.
The problem doesn't have a part 2. Completing the advent calendar
requires finishing all the others though. I'm missing day 23 part 2 and
the entirety of day 24.
2021-12-26 01:02:37 -03:00
Érico Nogueira 467c17eebe Add Advent 2021 - day 23.
Only part 1 so far, and it's quite slow.
2021-12-26 01:02:31 -03:00
Érico Nogueira 61a845cf75 Add Advent 2021 - day 22.
- test3.txt is my puzzle input
- two levels of recursion!
2021-12-22 23:12:43 -03:00
Érico Nogueira 9802996e71 Add Advent 2021 - day 21. 2021-12-21 04:07:26 -03:00
Érico Nogueira 92fe915c57 Add Advent 2021 - day 20. 2021-12-20 14:15:33 -03:00
Érico Nogueira 2d17e69ef1 Add Advent 2021 - day 19.
Takes 38 minutes to spit out a result, but at least it was a correct
result.
2021-12-19 23:50:19 -03:00
Érico Nogueira becc8a3487 Advent 2021, day 15: speed up.
Racket 8.3 had a performance regression that caused hashing pairs of
small numbers to take a long time. Using a vector made it substantially
faster (2 min -> 15 s).

See also [1] for upstream bug report.

[1] https://github.com/racket/racket/issues/4098
2021-12-18 21:54:43 -03:00
Érico Nogueira 87e6927028 Add Advent 2021 - day 18.
Lots and lots of recursion.

test6.txt is my puzzle input.
2021-12-18 19:34:58 -03:00
Érico Nogueira f259ef3441 Add Advent 2021 - day 17.
Slightly hacky solution, enabled by small input size:

- max number of recursions is arbitrary, found via testing
- bounds for x and minimal bound for y are analytic; max bound for y is
  from testing
2021-12-17 04:13:42 -03:00
Érico Nogueira c04a3f3314 Advent 2021, day 15: fix part 2.
- p2.rkt: going left and up is allowed, so add these moves to graph.
  This fixes our results
- p.py: correct implementation of p.rkt (that one is still broken)
- test4.txt: pre-expanded test input
2021-12-16 22:55:44 -03:00
Érico Nogueira 23f4c2b6ba Add Advent 2021 - day 15.
Still incomplete! Results for part 2, via either p.rkt or p2.rkt, aren't
correct.

- p.rkt: solves part 1 and part 2 if fed the pre-expanded map
- p2.rkt: solves part 2 by expanding the map itself
- test1.txt and test3.txt are the sample inputs, first for part 1 and
  then pre-expanded from part 2
- test2.txt is my puzzle input
2021-12-16 16:24:32 -03:00
Érico Nogueira d2c04effce Advent 2021, day 16: use bitwise-bit-field.
This allows us to parse the input as a big integer instead of an array
of bits. The operations were few enough that the speed up is minimal,
but it's still nicer code.
2021-12-16 05:33:55 -03:00
Érico Nogueira c6059bf54e Add Advent 2021 - day 16. 2021-12-16 04:19:02 -03:00
Érico Nogueira 78747594b7 Add Advent 2021 - day 14.
Two solutions: p.rkt is the naive solution and works for part 1, but
fails hard at part 2. It was slow enough I couldn't even get to memory
exhaustion. p2.rkt uses a hash map for pairs and a hash map for
character count, both of which are updated for each iteration. This one
can probably deal with any reasonable number of iterations.
2021-12-14 03:40:54 -03:00
Érico Nogueira 3bb8648786 Add Advent 2021 - day 13. 2021-12-13 02:45:01 -03:00
Érico Nogueira 30b0110035 Add Advent 2021 - day 12. 2021-12-12 04:26:45 -03:00
Érico Nogueira 31e1fa2682 Add Advent 2021 - day 11. 2021-12-11 03:32:37 -03:00
Érico Nogueira a28a3d1c6e Add Advent 2021 - day 10. 2021-12-10 02:50:15 -03:00
Érico Nogueira d447ffce88 Add Advent 2021 - day 9. 2021-12-09 03:04:52 -03:00
Érico Nogueira c52bce683b Advent 2021, day 8: use actual hash sets.
Smaller code and intentions are clearer.
2021-12-08 17:31:41 -03:00
Érico Nogueira 157c011341 Add 2021 advent - day 8. 2021-12-08 14:45:23 -03:00
Érico Nogueira 990c2e4909 Add 2021 advent - day 7. 2021-12-07 02:17:28 -03:00
Érico Nogueira a3a68ad3fc Advent 2021, make loading faster.
Use '#lang racket/base' where possible.
2021-12-06 05:25:42 -03:00
Érico Nogueira cd9bd8fa42 Advent 2021, fix formatting.
https://docs.racket-lang.org/style/Textual_Matters.html
2021-12-06 05:19:27 -03:00
Érico Nogueira 1b8e1f526b Add 2021 advent - day 6. 2021-12-06 03:06:51 -03:00
Érico Nogueira 0ec1ae8410 Advent 2021, day 5: implement part 2.
Also clean up leftover piece :P
2021-12-05 05:00:31 -03:00
Érico Nogueira 3c115266de Advent 2021, day 5: simplify and speed up a bunch.
Execution time is now irrelevant.

Could probably be further simplified for just counting members when they
are present in hash table, but no need for it yet.
2021-12-05 04:39:28 -03:00
Érico Nogueira 6557cbef12 Add 2021 advent - day 5. 2021-12-05 04:39:23 -03:00
Érico Nogueira 16a0303730 Add 2021 advent - day 4.
Learn mutable pairs, for* loops.
2021-12-04 03:33:24 -03:00
Érico Nogueira eeccb37e85 Add 2021 advent - day 3. 2021-12-03 12:35:21 -03:00
Érico Nogueira 62ff778bcc Advent 2021, day 2: simplify conditionals.
We have now learned about (when).
2021-12-02 11:34:46 -03:00
Érico Nogueira ccf4d551fc Add 2021 advent - day 2. 2021-12-02 11:31:39 -03:00
Érico Nogueira d8888bad83 Add 2021 advent - day 1.
Time to learn Racket/Scheme?
2021-12-01 15:57:40 -03:00
Érico Nogueira 462062498f Add 2020 advent.
I only completed up to day 5.
2021-12-01 15:57:08 -03:00