-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
20 changed files
with
99 additions
and
96 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,6 +1,6 @@ | ||
{ | ||
"schemaVersion": 1, | ||
"label": "Advent of TypeScript 2024", | ||
"message": "3/25", | ||
"message": "4/25", | ||
"color": "orange" | ||
} |
Submodule resources
updated
from b630d0 to ab58d4
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
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
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,8 +1,24 @@ | ||
import { task } from '@alexaegis/advent-of-code-lib'; | ||
import { Direction, task } from '@alexaegis/advent-of-code-lib'; | ||
import packageJson from '../package.json' assert { type: 'json' }; | ||
|
||
export const p1 = (_input: string): number => { | ||
return 0; | ||
}; | ||
const searchWord = 'XMAS'; | ||
|
||
await task(p1, packageJson.aoc); // 0 ~0.09ms | ||
export const p1 = (input: string): number => | ||
input | ||
.toGridGraph({ | ||
connectionDirections: Direction.allDirections, | ||
}) | ||
.nodeValues.filter((node) => node.toString() === searchWord[0]) | ||
.map((node) => { | ||
return Direction.allDirections.filter((direction) => { | ||
let walkResult = node.walkDirection( | ||
direction, | ||
(_next, distance) => distance < searchWord.length - 1, | ||
); | ||
const word = walkResult.nodes.map((n) => n.toString()).join(''); | ||
return word === searchWord; | ||
}).length; | ||
}) | ||
.sum(); | ||
|
||
await task(p1, packageJson.aoc); // 2427 ~91.00ms |
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
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,8 +1,38 @@ | ||
import { task } from '@alexaegis/advent-of-code-lib'; | ||
import { Direction, GridGraphNode, task } from '@alexaegis/advent-of-code-lib'; | ||
import packageJson from '../package.json' assert { type: 'json' }; | ||
|
||
export const p2 = (_input: string): number => { | ||
return 0; | ||
const isArmCorrect = ( | ||
nodeA: GridGraphNode | undefined, | ||
nodeB: GridGraphNode | undefined, | ||
): boolean => { | ||
if (nodeA === undefined || nodeB === undefined) { | ||
return false; | ||
} | ||
|
||
return ( | ||
(nodeA.toString() === 'S' && nodeB.toString() === 'M') || | ||
(nodeA.toString() === 'M' && nodeB.toString() === 'S') | ||
); | ||
}; | ||
|
||
export const p2 = (input: string): number => { | ||
let g = input.toGridGraph({ | ||
connectionDirections: Direction.allDirections, | ||
}); | ||
return g.nodeValues | ||
.filter((node) => node.toString() === 'A') | ||
.filter((node) => { | ||
let arm1Correct = isArmCorrect( | ||
node.getNeighbour(Direction.NORTHEAST), | ||
node.getNeighbour(Direction.SOUTHWEST), | ||
); | ||
let arm2Correct = isArmCorrect( | ||
node.getNeighbour(Direction.NORTHWEST), | ||
node.getNeighbour(Direction.SOUTHEAST), | ||
); | ||
|
||
return arm1Correct && arm2Correct; | ||
}).length; | ||
}; | ||
|
||
await task(p2, packageJson.aoc); // 0 ~0.09ms | ||
await task(p2, packageJson.aoc); // 1900 ~79.72ms |
This file was deleted.
Oops, something went wrong.
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
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
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
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
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
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
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
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
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
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
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.