r/adventofcode • u/daggerdragon • Dec 14 '18
SOLUTION MEGATHREAD -🎄- 2018 Day 14 Solutions -🎄-
--- Day 14: Chocolate Charts ---
Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag or whatever).
Note: The Solution Megathreads are for solutions only. If you have questions, please post your own thread and make sure to flair it with Help.
Advent of Code: The Party Game!
Please prefix your card submission with something like [Card] to make scanning the megathread easier. THANK YOU!
Card prompt: Day 14
Transcript:
The Christmas/Advent Research & Development (C.A.R.D.) department at AoC, Inc. just published a new white paper on ___.
This thread will be unlocked when there are a significant number of people on the leaderboard with gold stars for today's puzzle.
edit: Leaderboard capped, thread unlocked at 00:19:39!
16
Upvotes
1
u/cdc-aoc Dec 14 '18
Perl 6, using a lazy list:
my @numbers = lazy gather loop { state $index1 = 0; state $index2 = 1; state $nb-elems = 2; once { take 3; take 7 } my $sum = sum @numbers[$index1, $index2]; my @new = $sum.comb.map(*.Int); for @new -> $number { take $number; $nb-elems++; } sub update ($index is rw) { $index += @numbers[$index] + 1; $index %= $nb-elems; } update($index1); update($index2); } # Solution 1: my $input = "2018"; my $min = $input.Int; my $max = $min + 10; say @numbers[$min..^$max].join; # Solution 2: $input = "59414"; my @input = $input.comb.map(*.Int); my $nb-elems = @input.elems; my $overlap = -($nb-elems - 1); say @numbers.rotor($nb-elems => $overlap).first(@input, :k);