-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
29 lines (23 loc) · 860 Bytes
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import assert from "assert";
import { playQuantumGame } from "./QuantumGame";
import { parseGameStart } from "./Game";
import { playDeterministicGame } from "./DeterministicGame";
// https://adventofcode.com/2021/day/21
// Data
const example = parseGameStart("example.txt");
const input = parseGameStart("input.txt");
// Part one example
const exampleResult = playDeterministicGame(example);
assert.equal(exampleResult.rolls * exampleResult.losingScore, 739_785);
// Part one
const result = playDeterministicGame(input);
console.log(
"Part one - rolls times loser's score: ",
result.rolls * result.losingScore
);
// Part two example
const quantumExample = playQuantumGame(example);
assert.equal(quantumExample, 444356092776315n);
// Part two
const quantumResult = playQuantumGame(input);
console.log("Part two - multiverse winner: ", quantumResult);