Skip to content

Commit fef58b6

Browse files
authored
Merge pull request #48 from weaponsforge/feat/weaponsforge-22
feat: day 14 restroom redoubt 20241214
2 parents 9ae5b27 + 6f3919f commit fef58b6

File tree

17 files changed

+1037
-16
lines changed

17 files changed

+1037
-16
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ This repository contains solutions and a local development environment for the [
2424
- Day 11: Plutonian Pebbles [[link]](/src/2024/2024-12-11/README.md)
2525
- Day 12: Garden Groups [[link]](/src/2024/2024-12-12/README.md)
2626
- Day 13: Claw Contraption [[link]](/src/2024/2024-12-13/README.md)
27+
- Day 14: Restroom Redoubt [[link]](/src/2024/2024-12-14/README.md)
2728

2829
</details>
2930

src/2024/2024-12-10/lib/scoresRatings.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ const findPaths = (pointVector: PointDirection, data: number[][], isRating: bool
2828
if (step === undefined) continue
2929
const pt = getCoordinateSymbol(step, data)
3030

31+
if (pt === undefined) continue
32+
3133
if (pt.symbol === 9) {
3234
if (isRating) {
3335
// Rating: count all trails ending in 9's
@@ -76,6 +78,8 @@ export const countTrailScores = (data: number[][], params?: InputOptions): Trail
7678
}
7779

7880
const pt = getCoordinateSymbol(starts[i] as Point, data)
81+
if (!pt) continue
82+
7983
activeZeroIndex = pt.coordinate
8084
scores[activeZeroIndex] = []
8185

src/2024/2024-12-13/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const data = fileReader('../input.txt')
66
const data2 = fileReader('../input2.txt')
77

88
/**
9-
* Part 1/2 of the 2024-12-14 quiz
9+
* Part 1/2 of the 2024-12-13 quiz
1010
* Counts the number of tokens needed to win all possible prizes.
1111
*/
1212
const quiz20241213_01 = () => {
@@ -17,7 +17,7 @@ const quiz20241213_01 = () => {
1717
}
1818

1919
/**
20-
* Part 2/2 of the 2024-12-14 quiz
20+
* Part 2/2 of the 2024-12-13 quiz
2121
* Counts the number of tokens needed to win all possible prizes,
2222
* adjusted to the additional `10000000000000` of the prize coordinates
2323
*/

src/2024/2024-12-14/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
## Day 14: Restroom Redout
2+
3+
Visit the Advent of Code website for more information on this puzzle at:
4+
5+
**Source:** https://adventofcode.com/2024/day/14<br>
6+
**Status:** Complete ⭐⭐
7+
8+
## Code
9+
10+
### `findEasterEgg.ts`
11+
12+
- **`findEasterEgg()`** - Counts the no. of seconds before robots display (form) the Christmas Tree easter egg.
13+
> **NOTE:** I got tips and hints from about the figure of the Christmas tree [here](https://elixirforum.com/t/advent-of-code-2024-day-14/68091/3) after trying to observe for a 🎄 pattern in grid renders per second iteration.
14+
15+
### `safetyFactor.ts`
16+
17+
- **`calculateSafetyFactor()`** - Counts the safety factor after `params.seconds` of simulating moving the robots.
18+
19+
### `board.ts`
20+
21+
**Board** class
22+
23+
- Manages the `Grid`-like 2D string array, methods, and properties in which robots run
24+
- **`create()`** - Creates a blank `this.length` x `this.width` board, clearing
25+
- **`findQuadrants()`** - Finds the four (4) main quadrants of `this.grid`, each containing a set of inclusive `start` and `end` coordinates.
26+
- **`getQuadrant()`** - Finds the quadrant `ID` of a `Point` within the `this.grid` 2D array.
27+
- **`moveRobot()`** - Moves a robot from a tile and updates the current and new tile's robot count
28+
- **`setRobot()`** - Sets a new robot into the `Board`'s robots list and marks its position in `this.grid[][]` array
29+
- **`setTileValue()`** - Sets the string value in the 2D `this.grid[][]` array
30+
- **`simulateRobotsWalk()`** - Move (walk) the robots by updating their positions by velocity by `seconds` times.
31+
- **`viewQuadrants()`** - Draws categorized symbols per quadrant on a temporary 2D array for visualization.

src/2024/2024-12-14/assets/sample.PNG

6.48 KB
Loading

0 commit comments

Comments
 (0)