Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- KX Community
- Advent of Code 2021

There's not much to do as you slowly descend to the bottom of the ocean. The submarine computer challenges you to a nice game of Dirac Dice.
This game consists of a single die, two pawns, and a game board with a circular track containing ten spaces marked 1 through 10 clockwise. Each player's starting space is chosen randomly (your puzzle input). Player 1 goes first.
Players take turns moving. On each player's turn, the player rolls the die three times and adds up the results. Then, the player moves their pawn that many times forward around the track (that is, moving clockwise on spaces in order of increasing value, wrapping back around to 1 after 10 ). So, if a player is on space 7 and they roll 2 , 2 , and 1 , they would move forward 5 times, to spaces 8 , 9 , 10 , 1 , and finally stopping on 2 .
After each player moves, they increase their score by the value of the space their pawn stopped on. Players' scores start at 0 . So, if the first player starts on space 7 and rolls a total of 5 , they would stop on space 2 and add 2 to their score (for a total score of 2 ). The game immediately ends as a win for any player whose score reaches at least 1000 .
Since the first game is a practice game, the submarine opens a compartment labeled deterministic dice and a 100-sided die falls out. This die always rolls 1 first, then 2 , then 3 , and so on up to 100 , after which it starts over at 1 again. Play using this die.
For example, given these starting positions:
Player 1 starting position: 4
Player 2 starting position: 8
This is how the game would go:
Player 1 rolls 1 + 2 + 3 and moves to space 10 for a total score of 10 .
Player 2 rolls 4 + 5 + 6 and moves to space 3 for a total score of 3 .
Player 1 rolls 7 + 8 + 9 and moves to space 4 for a total score of 14 .
Player 2 rolls 10 + 11 + 12 and moves to space 6 for a total score of 9 .
Player 1 rolls 13 + 14 + 15 and moves to space 6 for a total score of 20 .
Player 2 rolls 16 + 17 + 18 and moves to space 7 for a total score of 16 .
Player 1 rolls 19 + 20 + 21 and moves to space 6 for a total score of 26 .
Player 2 rolls 22 + 23 + 24 and moves to space 6 for a total score of 22 .
...after many turns...
Player 2 rolls 82 + 83 + 84 and moves to space 6 for a total score of 742 .
Player 1 rolls 85 + 86 + 87 and moves to space 4 for a total score of 990 .
Player 2 rolls 88 + 89 + 90 and moves to space 3 for a total score of 745 .
Player 1 rolls 91 + 92 + 93 and moves to space 10 for a final score, 1000 .
Since player 1 has at least 1000 points, player 1 wins and the game ends. At this point, the losing player had 745 points and the die had been rolled a total of 993 times; 745 * 993 = 739785 .
Play a practice game using the deterministic 100-sided die. The moment either player wins, what do you get if you multiply the score of the losing player by the number of times the die was rolled during the game?
All credit for the above puzzle goes to Eric Wastl and Advent of Code.
Don't forget to submit your solutions at adventofcode.com and join the KX leaderboard using code 1526329-bb0915a5.
... View more

With the scanners fully deployed, you turn their attention to mapping the floor of the ocean trench.
When you get back the image from the scanners, it seems to just be random noise. Perhaps you can combine an image enhancement algorithm and the input image (your puzzle input) to clean it up a little.
For example:
..#.#..#####.#.#.#.###.##.....###.##.#..###.####..#####..#....#..#..##..##
#..######.###...####..#..#####..##..#.#####...##.#.#..#.##..#.#......#.###
.######.###.####...#.##.##..#..#..#####.....#.#....###..#.##......#.....#.
.#..#..##..#...##.######.####.####.#.#...#.......#..#.#.#...####.##.#.....
.#..#...##.#.##..#...##.#.##..###.#......#.#.......#.#.#.####.###.##...#..
...####.#..#..#.##.#....##..#.####....##...##..#...#......#.#.......#.....
..##..####..#...#.#.#...##..#.#..###..#####........#..####......#..#
#..#.
#....
##..#
..#..
..###
The first section is the image enhancement algorithm. It is normally given on a single line, but it has been wrapped to multiple lines in this example for legibility. The second section is the input image, a two-dimensional grid of light pixels ( # ) and dark pixels ( . ).
The image enhancement algorithm describes how to enhance an image by simultaneously converting all pixels in the input image into an output image. Each pixel of the output image is determined by looking at a 3x3 square of pixels centered on the corresponding input image pixel. So, to determine the value of the pixel at (5,10) in the output image, nine pixels from the input image need to be considered: (4,9), (4,10), (4,11), (5,9), (5,10), (5,11), (6,9), (6,10), and (6,11). These nine input pixels are combined into a single binary number that is used as an index in the image enhancement algorithm string.
For example, to determine the output pixel that corresponds to the very middle pixel of the input image, the nine pixels marked by [...] would need to be considered:
# . . # .
#[. . .].
#[# . .]#
.[. # .].
. . # # #
Starting from the top-left and reading across each row, these pixels are ... , then #.. , then .#. ; combining these forms ...#...#. . By turning dark pixels ( . ) into 0 and light pixels ( # ) into 1 , the binary number 000100010 can be formed, which is 34 in decimal.
The image enhancement algorithm string is exactly 512 characters long, enough to match every possible 9-bit binary number. The first few characters of the string (numbered starting from zero) are as follows:
0 10 20 30 34 40 50 60 70
| | | | | | | | |
..#.#..#####.#.#.#.###.##.....###.##.#..###.####..#####..#....#..#..##..##
In the middle of this first group of characters, the character at index 34 can be found: # . So, the output pixel in the center of the output image should be # , a light pixel.
This process can then be repeated to calculate every pixel of the output image.
Through advances in imaging technology, the images being operated on here are infinite in size. Every pixel of the infinite output image needs to be calculated exactly based on the relevant pixels of the input image. The small input image you have is only a small region of the actual infinite input image; the rest of the input image consists of dark pixels ( . ). For the purposes of the example, to save on space, only a portion of the infinite-sized input and output images will be shown.
The starting input image, therefore, looks something like this, with more dark pixels ( . ) extending forever in every direction not shown here:
...............
...............
...............
...............
...............
.....#..#......
.....#.........
.....##..#.....
.......#.......
.......###.....
...............
...............
...............
...............
...............
By applying the image enhancement algorithm to every pixel simultaneously, the following output image can be obtained:
...............
...............
...............
...............
.....##.##.....
....#..#.#.....
....##.#..#....
....####..#....
.....#..##.....
......##..#....
.......#.#.....
...............
...............
...............
...............
Through further advances in imaging technology, the above output image can also be used as an input image! This allows it to be enhanced a second time:
...............
...............
...............
..........#....
....#..#.#.....
...#.#...###...
...#...##.#....
...#.....#.#...
....#.#####....
.....#.#####...
......##.##....
.......###.....
...............
...............
...............
Truly incredible - now the small details are really starting to come through. After enhancing the original input image twice, 35 pixels are lit.
Start with the original input image and apply the image enhancement algorithm twice, being careful to account for the infinite size of the images. How many pixels are lit in the resulting image?
All credit for the above puzzle goes to Eric Wastl and Advent of Code.
Don't forget to submit your solutions at adventofcode.com and join the KX leaderboard using code 1526329-bb0915a5.
... View more

Now, you need to figure out how to pilot this thing .
It seems like the submarine can take a series of commands like forward 1 , down 2 , or up 3 :
forward X increases the horizontal position by X units.
down X increases the depth by X units.
up X decreases the depth by X units.
Note that since you're on a submarine, down and up affect your depth, and so they have the opposite result of what you might expect.
The submarine seems to already have a planned course (your puzzle input). You should probably figure out where it's going. For example:
forward 5
down 5
forward 8
up 3
down 8
forward 2
Your horizontal position and depth both start at 0 . The steps above would then modify them as follows:
forward 5 adds 5 to your horizontal position, a total of 5 .
down 5 adds 5 to your depth, resulting in a value of 5 .
forward 8 adds 8 to your horizontal position, a total of 13 .
up 3 decreases your depth by 3 , resulting in a value of 2 .
down 8 adds 8 to your depth, resulting in a value of 10 .
forward 2 adds 2 to your horizontal position, a total of 15 .
After following these instructions, you would have a horizontal position of 15 and a depth of 10 . (Multiplying these together produces 150 .)
Calculate the horizontal position and depth you would have after following the planned course.
What do you get if you multiply your final horizontal position by your final depth?
All credit for the above puzzle goes to Eric Wastl and Advent of Code.
Don't forget to submit your solutions at adventofcode.com and join the KX leaderboard using code 1526329-bb0915a5.
... View more

A giant whale has decided your submarine is its next meal, and it's much faster than you are. There's nowhere to run!
Suddenly, a swarm of crabs (each in its own tiny submarine - it's too deep for them otherwise) zooms in to rescue you! They seem to be preparing to blast a hole in the ocean floor; sensors indicate a massive underground cave system just beyond where they're aiming!
The crab submarines all need to be aligned before they'll have enough power to blast a large enough hole for your submarine to get through. However, it doesn't look like they'll be aligned before the whale catches you! Maybe you can help?
There's one major catch - crab submarines can only move horizontally.
You quickly make a list of the horizontal position of each crab (your puzzle input). Crab submarines have limited fuel, so you need to find a way to make all of their horizontal positions match while requiring them to spend as little fuel as possible.
For example, consider the following horizontal positions:
16,1,2,0,4,2,7,1,2,14
This means there's a crab with horizontal position 16 , a crab with horizontal position 1 , and so on.
Each change of 1 step in horizontal position of a single crab costs 1 fuel. You could choose any horizontal position to align them all on, but the one that costs the least fuel is horizontal position 2 :
Move from 16 to 2 : 14 fuel
Move from 1 to 2 : 1 fuel
Move from 2 to 2 : 0 fuel
Move from 0 to 2 : 2 fuel
Move from 4 to 2 : 2 fuel
Move from 2 to 2 : 0 fuel
Move from 7 to 2 : 5 fuel
Move from 1 to 2 : 1 fuel
Move from 2 to 2 : 0 fuel
Move from 14 to 2 : 12 fuel
This costs a total of 37 fuel. This is the cheapest possible outcome; more expensive outcomes include aligning at position 1 ( 41 fuel), position 3 ( 39 fuel), or position 10 ( 71 fuel).
Determine the horizontal position that the crabs can align to using the least fuel possible. How much fuel must they spend to align to that position?
All credit for the above puzzle goes to Eric Wastl and Advent of Code.
Don't forget to submit your solutions at adventofcode.com and join the KX leaderboard using code 1526329-bb0915a5.
... View more

Congratulations to our puzzlers for completing week 3 of AOC! Time flies when you're having fun.
Here are the Top 50 on our KX Community Leaderboard:
2079 * * * * * * * * * * * * * * * * * @WillDaSilva
2059 * * * * * * * * * * * * * * * * * adventofk
2011 * * * * * * * * * * * * * * * * * @adotsch
1945 * * * * * * * * * * * * * * * * * sean185
1931 * * * * * * * * * * * * * * * * * @ashahbaz
1820 * * * * * * * * * * * * * * * * * @Lukasz_Kedzior
1751 * * * * * * * * * * * * * * * * * @gyorokpeter
1714 * * * * * * * * * * * * * * * * * Mark Street
1667 * * * * * * * * * * * * * * * * * @sanderroomuscwo
1646 * * * * * * * * * * * * * * * * * @Calum_H
1583 * * * * * * * * * * * * * * * * * Christopher Nguyen
1458 * * * * * * * * * * * * * * * * * Shaked Koplewitz
1441 * * * * * * * * * * * * * * * * * @cillian_reilly2
1416 * * * * * * * * * * * * * * * * * Roman Buchatsky
1357 * * * * * * * * * * * * * * * * * rak1507
1163 * * * * * * * * * * * * * * * * * @cathaloneill
1111 * * * * * * * * * * * * * * * * * @Jason_Fealy
1106 * * * * * * * * * * * * * * * * * (anonymous user #19765)
1033 * * * * * * * * * * * * * * * * * @pmurphy3
1014 * * * * * * * * * * * * * * * * * @rathore_ajay
889 * * * * * * * * * * * * * * * * * alexander livingston
872 * * * * * * * * * * * * * * * * * nabeel-ms
814 * * * * * * * * * * * * * * * * * Jack Ballinger
797 * * * * * * * * * * * * * * * * * @Angus
721 * * * * * * * * * * * * * * * * * joycetandev
635 * * * * * * * * * * * * * * * * * @grobertson
601 * * * * * * * * * * * * * * * * * Eoin Cunning
601 * * * * * * * * * * * * * * * * * TadhgD
581 * * * * * * * * * * * * * * * * * @jkane2
544 * * * * * * * * * * * * * * * * * @paulgrainger
542 * * * * * * * * * * * * * * * * * (anonymous user #1471301)
510 * * * * * * * * * * * * * * * * * @SJT
450 * * * * * * * * * * * * * * * * * scrawley
433 * * * * * * * * * * * * * * * * * @sujoy13
383 * * * * * * * * * * * * * * * * * Aaron Tan
313 * * * * * * * * * * * * * * * * * David Singleton
301 * * * * * * * * * * * * * * * * * graceheghe
288 * * * * * * * * * * * * * * * * * @max_tsuno
220 * * * * * * * * * * * * * * * * * @lmcdermid
207 * * * * * * * * * * * * * * * * * @kcorcoran
207 * * * * * * * * * * * * * * * * * M_G4
1 80 * * * * * * * * * * * * * * * * * @RobertS
179 * * * * * * * * * * * * * * * * * avec-zz
146 * * * * * * * * * * * * * * * * * @Michaela
140 * * * * * * * * * * * * * * * * * @derekwisong
135 * * * * * * * * * * * * * * * * * pomtojoer
125 * * * * * * * * * * * * * * * * * @WilliamO1
119 * * * * * * * * * * * * * * * * * Ze Xuan Ong
113 * * * * * * * * * * * * * * * * * @pmallon
96 * * * * * * * * * * * * * * * * * @paul_wooding
If your AOC username is above but you're not tagged, send me a message and I'll tag you 😃
Only one more week to go!
... View more

Group Hub Information

For general discussion and a bit of friendly KX competition to get us into the festive spirit!

65 members

Owned by leah_marie_s, Laura

Open group

Created 2021.11.30

Main Office Contacts

**EMEA**

Tel: +44 (0)28 3025 2242

**AMERICAS**

Tel: +1 (212) 447 6700

**APAC**

Tel: +61 (0)2 9236 5700

Useful Information

Resources

Popular Links

Follow Us

KX. All Rights Reserved.

KX and kdb+ are registered trademarks of KX Systems, Inc., a subsidiary of FD Technologies plc.