-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
137 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
{ | ||
"year": 2023, | ||
"day": 20, | ||
"level": "first", | ||
"level": "second", | ||
"title": "Pulse Propagation", | ||
"stars": null, | ||
"solution": {}, | ||
"stars": 1, | ||
"solution": { | ||
"first": "886701120" | ||
}, | ||
"input": "%jb -> ps\n%cm -> ps, tm\n%sl -> ml, cp\n%qr -> ml\n%hf -> kh, jg\n%jg -> kk\n%jt -> pq\n%qv -> kv\n%rj -> mm, kh\n%kf -> xt\n%kx -> vk, mk\n%dq -> qn\n&ps -> xc, mq, jt, zs, sr, nt, pq\n%jk -> hh, ps\n%rr -> mk, nh\n%hs -> kh, mb\n%mg -> mk, kf\n%xt -> dq, mk\n&xc -> zh\n%mq -> nt\n%nh -> bm\n&ml -> bp, gd, qv, kq\n%md -> hs\n%vk -> mk, vl\n%mm -> kh\n&th -> zh\n&zh -> rx\n%kc -> ps, jk\n%kk -> dm\n%jn -> ll, ml\n&pd -> zh\n&kh -> jg, qx, md, th, hf, dm, kk\n%pp -> kh, md\n%zf -> ml, bd\n%qx -> pp\n&mk -> kf, qn, nh, pd, dq, mg, bm\n%qn -> rr\n%mb -> qb, kh\n%nt -> jt\n%vl -> zk, mk\n%gd -> ml, rm\n%hh -> ps, jb\n%tm -> ps, mq\n%kv -> jn, ml\n%zs -> kc\n%ll -> ml, kq\n%cp -> qv, ml\n%rm -> sl, ml\n%bd -> qr, ml\n%dm -> qx\n%qb -> rj, kh\n%pq -> zs\n%bm -> kx\n%sr -> cm, ps\n%zk -> mk\nbroadcaster -> sr, gd, mg, hf\n%kq -> zf\n&bp -> zh\n", | ||
"brief": { | ||
"first": "With your help, the Elves manage to find the right parts and fix all of the machines. Now, they just need to send the command to boot up the machines and get the sand flowing again.\n\nThe machines are far apart and wired together with long *cables*. The cables don't connect to the machines directly, but rather to communication *modules* attached to the machines that perform various initialization tasks and also act as communication relays.\n\nModules communicate using *pulses*. Each pulse is either a *high pulse* or a *low pulse*. When a module sends a pulse, it sends that type of pulse to each module in its list of *destination modules*.\n\nThere are several different types of modules:\n\n*Flip-flop* modules (prefix `%`) are either *on* or *off*; they are initially *off*. If a flip-flop module receives a high pulse, it is ignored and nothing happens. However, if a flip-flop module receives a low pulse, it *flips between on and off*. If it was off, it turns on and sends a high pulse. If it was on, it turns off and sends a low pulse.\n\n*Conjunction* modules (prefix `&`) *remember* the type of the most recent pulse received from *each* of their connected input modules; they initially default to remembering a *low pulse* for each input. When a pulse is received, the conjunction module first updates its memory for that input. Then, if it remembers *high pulses* for all inputs, it sends a *low pulse*; otherwise, it sends a *high pulse*.\n\nThere is a single *broadcast module* (named `broadcaster`). When it receives a pulse, it sends the same pulse to all of its destination modules.\n\nHere at Desert Machine Headquarters, there is a module with a single button on it called, aptly, the *button module*. When you push the button, a single *low pulse* is sent directly to the `broadcaster` module.\n\nAfter pushing the button, you must wait until all pulses have been delivered and fully handled before pushing it again. Never push the button if modules are still processing pulses.\n\nPulses are always processed *in the order they are sent*. So, if a pulse is sent to modules `a`, `b`, and `c`, and then module `a` processes its pulse and sends more pulses, the pulses sent to modules `b` and `c` would have to be handled first.\n\nThe module configuration (your puzzle input) lists each module. The name of the module is preceded by a symbol identifying its type, if any. The name is then followed by an arrow and a list of its destination modules. For example:\n\n```\nbroadcaster -> a, b, c\n%a -> b\n%b -> c\n%c -> inv\n&inv -> a\n\n```\n\nIn this module configuration, the broadcaster has three destination modules named `a`, `b`, and `c`. Each of these modules is a flip-flop module (as indicated by the `%` prefix). `a` outputs to `b` which outputs to `c` which outputs to another module named `inv`. `inv` is a conjunction module (as indicated by the `&` prefix) which, because it has only one input, acts like an inverter (it sends the opposite of the pulse type it receives); it outputs to `a`.\n\nBy pushing the button once, the following pulses are sent:\n\n```\nbutton -low-> broadcaster\nbroadcaster -low-> a\nbroadcaster -low-> b\nbroadcaster -low-> c\na -high-> b\nb -high-> c\nc -high-> inv\ninv -low-> a\na -low-> b\nb -low-> c\nc -low-> inv\ninv -high-> a\n\n```\n\nAfter this sequence, the flip-flop modules all end up *off*, so pushing the button again repeats the same sequence.\n\nHere's a more interesting example:\n\n```\nbroadcaster -> a\n%a -> inv, con\n&inv -> b\n%b -> con\n&con -> output\n\n```\n\nThis module configuration includes the `broadcaster`, two flip-flops (named `a` and `b`), a single-input conjunction module (`inv`), a multi-input conjunction module (`con`), and an untyped module named `output` (for testing purposes). The multi-input conjunction module `con` watches the two flip-flop modules and, if they're both on, sends a *low pulse* to the `output` module.\n\nHere's what happens if you push the button once:\n\n```\nbutton -low-> broadcaster\nbroadcaster -low-> a\na -high-> inv\na -high-> con\ninv -low-> b\ncon -high-> output\nb -high-> con\ncon -low-> output\n\n```\n\nBoth flip-flops turn on and a low pulse is sent to `output`! However, now that both flip-flops are on and `con` remembers a high pulse from each of its two inputs, pushing the button a second time does something different:\n\n```\nbutton -low-> broadcaster\nbroadcaster -low-> a\na -low-> inv\na -low-> con\ninv -high-> b\ncon -high-> output\n\n```\n\nFlip-flop `a` turns off! Now, `con` remembers a low pulse from module `a`, and so it sends only a high pulse to `output`.\n\nPush the button a third time:\n\n```\nbutton -low-> broadcaster\nbroadcaster -low-> a\na -high-> inv\na -high-> con\ninv -low-> b\ncon -low-> output\nb -low-> con\ncon -high-> output\n\n```\n\nThis time, flip-flop `a` turns on, then flip-flop `b` turns off. However, before `b` can turn off, the pulse sent to `con` is handled first, so it *briefly remembers all high pulses* for its inputs and sends a low pulse to `output`. After that, flip-flop `b` turns off, which causes `con` to update its state and send a high pulse to `output`.\n\nFinally, with `a` on and `b` off, push the button a fourth time:\n\n```\nbutton -low-> broadcaster\nbroadcaster -low-> a\na -low-> inv\na -low-> con\ninv -high-> b\ncon -high-> output\n\n```\n\nThis completes the cycle: `a` turns off, causing `con` to remember only low pulses and restoring all modules to their original states.\n\nTo get the cables warmed up, the Elves have pushed the button `1000` times. How many pulses got sent as a result (including the pulses sent by the button itself)?\n\nIn the first example, the same thing happens every time the button is pushed: `8` low pulses and `4` high pulses are sent. So, after pushing the button `1000` times, `8000` low pulses and `4000` high pulses are sent. Multiplying these together gives `*32000000*`.\n\nIn the second example, after pushing the button `1000` times, `4250` low pulses and `2750` high pulses are sent. Multiplying these together gives `*11687500*`.\n\nConsult your module configuration; determine the number of low pulses and high pulses that would be sent after pushing the button `1000` times, waiting for all pulses to be fully handled after each push of the button. *What do you get if you multiply the total number of low pulses sent by the total number of high pulses sent?*\n\nTo begin, [get your puzzle input](20/input).\n\nAnswer:" | ||
"first": "With your help, the Elves manage to find the right parts and fix all of the machines. Now, they just need to send the command to boot up the machines and get the sand flowing again.\n\nThe machines are far apart and wired together with long *cables*. The cables don't connect to the machines directly, but rather to communication *modules* attached to the machines that perform various initialization tasks and also act as communication relays.\n\nModules communicate using *pulses*. Each pulse is either a *high pulse* or a *low pulse*. When a module sends a pulse, it sends that type of pulse to each module in its list of *destination modules*.\n\nThere are several different types of modules:\n\n*Flip-flop* modules (prefix `%`) are either *on* or *off*; they are initially *off*. If a flip-flop module receives a high pulse, it is ignored and nothing happens. However, if a flip-flop module receives a low pulse, it *flips between on and off*. If it was off, it turns on and sends a high pulse. If it was on, it turns off and sends a low pulse.\n\n*Conjunction* modules (prefix `&`) *remember* the type of the most recent pulse received from *each* of their connected input modules; they initially default to remembering a *low pulse* for each input. When a pulse is received, the conjunction module first updates its memory for that input. Then, if it remembers *high pulses* for all inputs, it sends a *low pulse*; otherwise, it sends a *high pulse*.\n\nThere is a single *broadcast module* (named `broadcaster`). When it receives a pulse, it sends the same pulse to all of its destination modules.\n\nHere at Desert Machine Headquarters, there is a module with a single button on it called, aptly, the *button module*. When you push the button, a single *low pulse* is sent directly to the `broadcaster` module.\n\nAfter pushing the button, you must wait until all pulses have been delivered and fully handled before pushing it again. Never push the button if modules are still processing pulses.\n\nPulses are always processed *in the order they are sent*. So, if a pulse is sent to modules `a`, `b`, and `c`, and then module `a` processes its pulse and sends more pulses, the pulses sent to modules `b` and `c` would have to be handled first.\n\nThe module configuration (your puzzle input) lists each module. The name of the module is preceded by a symbol identifying its type, if any. The name is then followed by an arrow and a list of its destination modules. For example:\n\n```\nbroadcaster -> a, b, c\n%a -> b\n%b -> c\n%c -> inv\n&inv -> a\n\n```\n\nIn this module configuration, the broadcaster has three destination modules named `a`, `b`, and `c`. Each of these modules is a flip-flop module (as indicated by the `%` prefix). `a` outputs to `b` which outputs to `c` which outputs to another module named `inv`. `inv` is a conjunction module (as indicated by the `&` prefix) which, because it has only one input, acts like an inverter (it sends the opposite of the pulse type it receives); it outputs to `a`.\n\nBy pushing the button once, the following pulses are sent:\n\n```\nbutton -low-> broadcaster\nbroadcaster -low-> a\nbroadcaster -low-> b\nbroadcaster -low-> c\na -high-> b\nb -high-> c\nc -high-> inv\ninv -low-> a\na -low-> b\nb -low-> c\nc -low-> inv\ninv -high-> a\n\n```\n\nAfter this sequence, the flip-flop modules all end up *off*, so pushing the button again repeats the same sequence.\n\nHere's a more interesting example:\n\n```\nbroadcaster -> a\n%a -> inv, con\n&inv -> b\n%b -> con\n&con -> output\n\n```\n\nThis module configuration includes the `broadcaster`, two flip-flops (named `a` and `b`), a single-input conjunction module (`inv`), a multi-input conjunction module (`con`), and an untyped module named `output` (for testing purposes). The multi-input conjunction module `con` watches the two flip-flop modules and, if they're both on, sends a *low pulse* to the `output` module.\n\nHere's what happens if you push the button once:\n\n```\nbutton -low-> broadcaster\nbroadcaster -low-> a\na -high-> inv\na -high-> con\ninv -low-> b\ncon -high-> output\nb -high-> con\ncon -low-> output\n\n```\n\nBoth flip-flops turn on and a low pulse is sent to `output`! However, now that both flip-flops are on and `con` remembers a high pulse from each of its two inputs, pushing the button a second time does something different:\n\n```\nbutton -low-> broadcaster\nbroadcaster -low-> a\na -low-> inv\na -low-> con\ninv -high-> b\ncon -high-> output\n\n```\n\nFlip-flop `a` turns off! Now, `con` remembers a low pulse from module `a`, and so it sends only a high pulse to `output`.\n\nPush the button a third time:\n\n```\nbutton -low-> broadcaster\nbroadcaster -low-> a\na -high-> inv\na -high-> con\ninv -low-> b\ncon -low-> output\nb -low-> con\ncon -high-> output\n\n```\n\nThis time, flip-flop `a` turns on, then flip-flop `b` turns off. However, before `b` can turn off, the pulse sent to `con` is handled first, so it *briefly remembers all high pulses* for its inputs and sends a low pulse to `output`. After that, flip-flop `b` turns off, which causes `con` to update its state and send a high pulse to `output`.\n\nFinally, with `a` on and `b` off, push the button a fourth time:\n\n```\nbutton -low-> broadcaster\nbroadcaster -low-> a\na -low-> inv\na -low-> con\ninv -high-> b\ncon -high-> output\n\n```\n\nThis completes the cycle: `a` turns off, causing `con` to remember only low pulses and restoring all modules to their original states.\n\nTo get the cables warmed up, the Elves have pushed the button `1000` times. How many pulses got sent as a result (including the pulses sent by the button itself)?\n\nIn the first example, the same thing happens every time the button is pushed: `8` low pulses and `4` high pulses are sent. So, after pushing the button `1000` times, `8000` low pulses and `4000` high pulses are sent. Multiplying these together gives `*32000000*`.\n\nIn the second example, after pushing the button `1000` times, `4250` low pulses and `2750` high pulses are sent. Multiplying these together gives `*11687500*`.\n\nConsult your module configuration; determine the number of low pulses and high pulses that would be sent after pushing the button `1000` times, waiting for all pulses to be fully handled after each push of the button. *What do you get if you multiply the total number of low pulses sent by the total number of high pulses sent?*\n\nYour puzzle answer was `886701120`.\n\nThe first half of this puzzle is complete! It provides one gold star: \\*\n\n\\--- Part Two ---\n----------\n\nThe final machine responsible for moving the sand down to Island Island has a module attached named `rx`. The machine turns on when a *single low pulse* is sent to `rx`.\n\nReset all modules to their default states. Waiting for all pulses to be fully handled after each button press, *what is the fewest number of button presses required to deliver a single low pulse to the module named `rx`?*\n\nAnswer:\n\nAlthough it hasn't changed, you can still [get your puzzle input](20/input)." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.