Day 8: Haunted Wasteland Quest
This commit is contained in:
parent
e2a6188d9d
commit
bb5cdf04f2
|
@ -11,6 +11,9 @@ I don't know why I am spending my time this way, but I am trying to get through
|
|||
[[https://adventofcode.com/][Advent of Code]]. I decided to use [[https://call-cc.org][Chicken Scheme]], and I am trying to use as few (if any) extensions,
|
||||
for an extra challenge.
|
||||
|
||||
/*This may or may not be the original document ([[./chicken-src.org][=chicken-src.org=]]) or its weave for reading
|
||||
([[./chicken.org][=chicken.org=]]). Choose wisely.*/
|
||||
|
||||
* Day 1: Trebuchet?!
|
||||
:PROPERTIES:
|
||||
:header-args:scheme: :eval no
|
||||
|
@ -5292,6 +5295,44 @@ JJJJJ 565
|
|||
|
||||
** Part One
|
||||
|
||||
*** Quest
|
||||
|
||||
You're still riding a camel across Desert Island when you spot a sandstorm quickly approaching. When you turn to warn the Elf, she disappears before your eyes! To be fair, she had just finished warning you about *ghosts* a few minutes ago.
|
||||
|
||||
One of the camel's pouches is labeled "maps" - sure enough, it's full of documents (your puzzle input) about how to navigate the desert. At least, you're pretty sure that's what they are; one of the documents contains a list of left/right instructions, and the rest of the documents seem to describe some kind of *network* of labeled nodes.
|
||||
|
||||
It seems like you're meant to use the *left/right* instructions to *navigate the network*. Perhaps if you have the camel follow the same instructions, you can escape the haunted wasteland!
|
||||
|
||||
After examining the maps for a bit, two nodes stick out: =AAA= and =ZZZ=. You feel like =AAA= is where you are now, and you have to follow the left/right instructions until you reach =ZZZ=.
|
||||
|
||||
This format defines each node of the network individually. For example:
|
||||
|
||||
#+begin_example
|
||||
RL
|
||||
|
||||
AAA = (BBB, CCC)
|
||||
BBB = (DDD, EEE)
|
||||
CCC = (ZZZ, GGG)
|
||||
DDD = (DDD, DDD)
|
||||
EEE = (EEE, EEE)
|
||||
GGG = (GGG, GGG)
|
||||
ZZZ = (ZZZ, ZZZ)
|
||||
#+end_example
|
||||
|
||||
Starting with =AAA=, you need to *look up the next element* based on the next left/right instruction in your input. In this example, start with =AAA= and go *right* (=R=) by choosing the right element of =AAA=, *=CCC=*. Then, =L= means to choose the *left* element of =CCC=, *=ZZZ=*. By following the left/right instructions, you reach =ZZZ= in *=2=* steps.
|
||||
|
||||
Of course, you might not find =ZZZ= right away. If you run out of left/right instructions, repeat the whole sequence of instructions as necessary: =RL= really means =RLRLRLRLRLRLRLRL...= and so on. For example, here is a situation that takes *=6=* steps to reach =ZZZ=:
|
||||
|
||||
#+begin_example
|
||||
LLR
|
||||
|
||||
AAA = (BBB, BBB)
|
||||
BBB = (AAA, ZZZ)
|
||||
ZZZ = (ZZZ, ZZZ)
|
||||
#+end_example
|
||||
|
||||
Starting at =AAA=, follow the left/right instructions. *How many steps are required to reach =ZZZ=*?
|
||||
|
||||
** Part Two
|
||||
|
||||
** Puzzle Input
|
||||
|
|
50
chicken.org
50
chicken.org
|
@ -1,4 +1,4 @@
|
|||
# Created 2023-12-08 Fri 10:17
|
||||
# Created 2023-12-08 Fri 10:45
|
||||
#+title: Advent Of Code with Chicken Scheme
|
||||
#+author: Daniel Ziltener
|
||||
#+export_file_name: chicken.org
|
||||
|
@ -9,6 +9,9 @@
|
|||
I don't know why I am spending my time this way, but I am trying to get through this year's
|
||||
[[https://adventofcode.com/][Advent of Code]]. I decided to use [[https://call-cc.org][Chicken Scheme]], and I am trying to use as few (if any) extensions,
|
||||
for an extra challenge.
|
||||
|
||||
/*This may or may not be the original document ([[file:./chicken-src.org][=chicken-src.org=]]) or its weave for reading
|
||||
([[file:./chicken.org][=chicken.org=]]). Choose wisely.*/
|
||||
* Day 1: Trebuchet?!
|
||||
** Part One
|
||||
|
||||
|
@ -3748,10 +3751,10 @@ Every hand is exactly one *type*. From strongest to weakest, they are:
|
|||
<syntax> (##core#begin ((and (= 3 (car frequencies)) (= 2 (cadr frequencies))) (hand-type-rec-set! hand (alist-ref #:full-house hand-types))))
|
||||
<syntax> ((and (= 3 (car frequencies)) (= 2 (cadr frequencies))) (hand-type-rec-set! hand (alist-ref #:full-house hand-types)))
|
||||
<syntax> (and (= 3 (car frequencies)) (= 2 (cadr frequencies)))
|
||||
<syntax> (##core#if (= 3 (car frequencies)) (and26474 (= 2 (cadr frequencies))) #f)
|
||||
<syntax> (##core#if (= 3 (car frequencies)) (and28710 (= 2 (cadr frequencies))) #f)
|
||||
<syntax> (= 3 (car frequencies))
|
||||
<syntax> (car frequencies)
|
||||
<syntax> (and26474 (= 2 (cadr frequencies)))
|
||||
<syntax> (and28710 (= 2 (cadr frequencies)))
|
||||
<syntax> (= 2 (cadr frequencies))
|
||||
<syntax> (cadr frequencies)
|
||||
<syntax> (hand-type-rec-set! hand (alist-ref #:full-house hand-types))
|
||||
|
@ -3811,10 +3814,10 @@ Every hand is exactly one *type*. From strongest to weakest, they are:
|
|||
<syntax> (##core#begin ((and (= 2 (car frequencies)) (= 2 (cadr frequencies))) (hand-type-rec-set! hand (alist-ref #:two-pair hand-types))))
|
||||
<syntax> ((and (= 2 (car frequencies)) (= 2 (cadr frequencies))) (hand-type-rec-set! hand (alist-ref #:two-pair hand-types)))
|
||||
<syntax> (and (= 2 (car frequencies)) (= 2 (cadr frequencies)))
|
||||
<syntax> (##core#if (= 2 (car frequencies)) (and26693 (= 2 (cadr frequencies))) #f)
|
||||
<syntax> (##core#if (= 2 (car frequencies)) (and28929 (= 2 (cadr frequencies))) #f)
|
||||
<syntax> (= 2 (car frequencies))
|
||||
<syntax> (car frequencies)
|
||||
<syntax> (and26693 (= 2 (cadr frequencies)))
|
||||
<syntax> (and28929 (= 2 (cadr frequencies)))
|
||||
<syntax> (= 2 (cadr frequencies))
|
||||
<syntax> (cadr frequencies)
|
||||
<syntax> (hand-type-rec-set! hand (alist-ref #:two-pair hand-types))
|
||||
|
@ -7576,6 +7579,43 @@ Jump to [[#headline-83][day 8]].
|
|||
* Day 8: Haunted Wasteland
|
||||
** Part One
|
||||
|
||||
*** Quest
|
||||
|
||||
You're still riding a camel across Desert Island when you spot a sandstorm quickly approaching. When you turn to warn the Elf, she disappears before your eyes! To be fair, she had just finished warning you about *ghosts* a few minutes ago.
|
||||
|
||||
One of the camel's pouches is labeled "maps" - sure enough, it's full of documents (your puzzle input) about how to navigate the desert. At least, you're pretty sure that's what they are; one of the documents contains a list of left/right instructions, and the rest of the documents seem to describe some kind of *network* of labeled nodes.
|
||||
|
||||
It seems like you're meant to use the *left/right* instructions to *navigate the network*. Perhaps if you have the camel follow the same instructions, you can escape the haunted wasteland!
|
||||
|
||||
After examining the maps for a bit, two nodes stick out: =AAA= and =ZZZ=. You feel like =AAA= is where you are now, and you have to follow the left/right instructions until you reach =ZZZ=.
|
||||
|
||||
This format defines each node of the network individually. For example:
|
||||
|
||||
#+begin_example
|
||||
RL
|
||||
|
||||
AAA = (BBB, CCC)
|
||||
BBB = (DDD, EEE)
|
||||
CCC = (ZZZ, GGG)
|
||||
DDD = (DDD, DDD)
|
||||
EEE = (EEE, EEE)
|
||||
GGG = (GGG, GGG)
|
||||
ZZZ = (ZZZ, ZZZ)
|
||||
#+end_example
|
||||
|
||||
Starting with =AAA=, you need to *look up the next element* based on the next left/right instruction in your input. In this example, start with =AAA= and go *right* (=R=) by choosing the right element of =AAA=, *=CCC=*. Then, =L= means to choose the *left* element of =CCC=, *=ZZZ=*. By following the left/right instructions, you reach =ZZZ= in *=2=* steps.
|
||||
|
||||
Of course, you might not find =ZZZ= right away. If you run out of left/right instructions, repeat the whole sequence of instructions as necessary: =RL= really means =RLRLRLRLRLRLRLRL...= and so on. For example, here is a situation that takes *=6=* steps to reach =ZZZ=:
|
||||
|
||||
#+begin_example
|
||||
LLR
|
||||
|
||||
AAA = (BBB, BBB)
|
||||
BBB = (AAA, ZZZ)
|
||||
ZZZ = (ZZZ, ZZZ)
|
||||
#+end_example
|
||||
|
||||
Starting at =AAA=, follow the left/right instructions. *How many steps are required to reach =ZZZ=*?
|
||||
** Part Two
|
||||
|
||||
** Puzzle Input
|
||||
|
|
Loading…
Reference in New Issue