From b7ab02354ff2a1a60c7c37ad3d1a5528aee2f511 Mon Sep 17 00:00:00 2001 From: lukasbicus Date: Wed, 25 Sep 2024 09:23:39 +0200 Subject: [PATCH 01/10] Add day 14 puzzle. Define algorithm. --- scripts/aoc2015/day14/input.txt | 9 ++++++ scripts/aoc2015/day14/puzzle1.ts | 53 ++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 scripts/aoc2015/day14/input.txt create mode 100644 scripts/aoc2015/day14/puzzle1.ts diff --git a/scripts/aoc2015/day14/input.txt b/scripts/aoc2015/day14/input.txt new file mode 100644 index 0000000..1f40ea0 --- /dev/null +++ b/scripts/aoc2015/day14/input.txt @@ -0,0 +1,9 @@ +Vixen can fly 8 km/s for 8 seconds, but then must rest for 53 seconds. +Blitzen can fly 13 km/s for 4 seconds, but then must rest for 49 seconds. +Rudolph can fly 20 km/s for 7 seconds, but then must rest for 132 seconds. +Cupid can fly 12 km/s for 4 seconds, but then must rest for 43 seconds. +Donner can fly 9 km/s for 5 seconds, but then must rest for 38 seconds. +Dasher can fly 10 km/s for 4 seconds, but then must rest for 37 seconds. +Comet can fly 3 km/s for 37 seconds, but then must rest for 76 seconds. +Prancer can fly 9 km/s for 12 seconds, but then must rest for 97 seconds. +Dancer can fly 37 km/s for 1 seconds, but then must rest for 36 seconds. \ No newline at end of file diff --git a/scripts/aoc2015/day14/puzzle1.ts b/scripts/aoc2015/day14/puzzle1.ts new file mode 100644 index 0000000..352d1b7 --- /dev/null +++ b/scripts/aoc2015/day14/puzzle1.ts @@ -0,0 +1,53 @@ +/* +--- Day 14: Reindeer Olympics --- +This year is the Reindeer Olympics! Reindeer can fly at high speeds, but must rest occasionally to recover their energy. Santa would like to know which of his reindeer is fastest, and so he has them race. + +Reindeer can only either be flying (always at their top speed) or resting (not moving at all), and always spend whole seconds in either state. + +For example, suppose you have the following Reindeer: + +Comet can fly 14 km/s for 10 seconds, but then must rest for 127 seconds. +Dancer can fly 16 km/s for 11 seconds, but then must rest for 162 seconds. +After one second, Comet has gone 14 km, while Dancer has gone 16 km. After ten seconds, Comet has gone 140 km, while Dancer has gone 160 km. On the eleventh second, Comet begins resting (staying at 140 km), and Dancer continues on for a total distance of 176 km. On the 12th second, both reindeer are resting. They continue to rest until the 138th second, when Comet flies for another ten seconds. On the 174th second, Dancer flies for another 11 seconds. + +In this example, after the 1000th second, both reindeer are resting, and Comet is in the lead at 1120 km (poor Dancer has only gotten 1056 km by that point). So, in this situation, Comet would win (if the race ended at 1000 seconds). + +Given the descriptions of each reindeer (in your puzzle input), after exactly 2503 seconds, what distance has the winning reindeer traveled? + + +ALGORITHM: + +read input file +init all reindeer's +Lets have a board with each reindeer (check class) + +After each second, we should "tick" on reindeer + +What distance has reindeer traveled after 2503 seconds? +What distance has winning reindeer traveled? - What is the max distance on the board? + +========== +// Reindeer - class +fly speed (km/s) +fly limit (s) +rest limit (s) +currentActivity: Flying/Resting +timeSpentOnActivity (s) +distanceTraveled: (km) + +methods: +tick() +-if currentActivity is FLying + update distance traveled + increment time spent on Activity ++1 + if time spent on activity is equal to fly limit, + switch to resting activity + set time spent on Activity to 0 +else currentActivity is Resting + increment time spent on Activity ++1 + if time spent on activity is equal to rest limit, + switch to flying activity + set time spent on Activity to 0 +========== + + */ From daf8fc700fd64e0f9b972103be7e528ed39ddcd2 Mon Sep 17 00:00:00 2001 From: lukasbicus Date: Wed, 25 Sep 2024 09:24:11 +0200 Subject: [PATCH 02/10] Add simple input --- scripts/aoc2015/day14/simpleInput.txt | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 scripts/aoc2015/day14/simpleInput.txt diff --git a/scripts/aoc2015/day14/simpleInput.txt b/scripts/aoc2015/day14/simpleInput.txt new file mode 100644 index 0000000..3ef0b13 --- /dev/null +++ b/scripts/aoc2015/day14/simpleInput.txt @@ -0,0 +1,2 @@ +Comet can fly 14 km/s for 10 seconds, but then must rest for 127 seconds. +Dancer can fly 16 km/s for 11 seconds, but then must rest for 162 seconds. \ No newline at end of file From 203d9746be758b3cdc9f7750efe4df313f4b7f17 Mon Sep 17 00:00:00 2001 From: lukasbicus Date: Wed, 25 Sep 2024 09:30:45 +0200 Subject: [PATCH 03/10] Define parseReindeerLine, add tests. --- scripts/aoc2015/day14/utils.test.ts | 22 ++++++++++++++++++++++ scripts/aoc2015/day14/utils.ts | 8 ++++++++ 2 files changed, 30 insertions(+) create mode 100644 scripts/aoc2015/day14/utils.test.ts create mode 100644 scripts/aoc2015/day14/utils.ts diff --git a/scripts/aoc2015/day14/utils.test.ts b/scripts/aoc2015/day14/utils.test.ts new file mode 100644 index 0000000..6e22393 --- /dev/null +++ b/scripts/aoc2015/day14/utils.test.ts @@ -0,0 +1,22 @@ +import { assertEquals } from "@std/assert"; +import { describe, it } from "@std/testing/bdd"; +import { parseReindeerLine } from "./utils.ts"; + +describe("parseReindeerLine", function () { + it("should return null for invalid line", function () { + assertEquals(parseReindeerLine(""), null); + }); + it("should return object for valid line", function () { + assertEquals( + parseReindeerLine( + "Dancer can fly 16 km/s for 11 seconds, but then must rest for 162 seconds.", + ), + { + name: "Dancer", + speed: 16, + flyLimit: 11, + restLimit: 163, + }, + ); + }); +}); diff --git a/scripts/aoc2015/day14/utils.ts b/scripts/aoc2015/day14/utils.ts new file mode 100644 index 0000000..4835be1 --- /dev/null +++ b/scripts/aoc2015/day14/utils.ts @@ -0,0 +1,8 @@ +export function parseReindeerLine(line: string): { + name: string; + speed: number; + restLimit: number; + flyLimit: number; +} | null { + return null; +} From 3e8c3103ae6a0eb662142b60f6d7aea269780023 Mon Sep 17 00:00:00 2001 From: lukasbicus Date: Wed, 25 Sep 2024 10:05:07 +0200 Subject: [PATCH 04/10] Implement parseReindeerLine. --- scripts/aoc2015/day14/utils.test.ts | 2 +- scripts/aoc2015/day14/utils.ts | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/scripts/aoc2015/day14/utils.test.ts b/scripts/aoc2015/day14/utils.test.ts index 6e22393..75b0b07 100644 --- a/scripts/aoc2015/day14/utils.test.ts +++ b/scripts/aoc2015/day14/utils.test.ts @@ -15,7 +15,7 @@ describe("parseReindeerLine", function () { name: "Dancer", speed: 16, flyLimit: 11, - restLimit: 163, + restLimit: 162, }, ); }); diff --git a/scripts/aoc2015/day14/utils.ts b/scripts/aoc2015/day14/utils.ts index 4835be1..56bab76 100644 --- a/scripts/aoc2015/day14/utils.ts +++ b/scripts/aoc2015/day14/utils.ts @@ -1,8 +1,20 @@ +const reindeerRegex = + /(\w+) can fly (\d+) km\/s for (\d+) seconds, but then must rest for (\d+) seconds./; + export function parseReindeerLine(line: string): { name: string; speed: number; restLimit: number; flyLimit: number; } | null { - return null; + const match = line.match(reindeerRegex); + if (!match) { + return null; + } + return { + name: match[1], + speed: parseInt(match[2], 10), + flyLimit: parseInt(match[3], 10), + restLimit: parseInt(match[4], 10), + }; } From b9846a336a83710b16005e0ba7874383b2589cc3 Mon Sep 17 00:00:00 2001 From: lukasbicus Date: Wed, 25 Sep 2024 10:23:07 +0200 Subject: [PATCH 05/10] Implement simpleInput --- scripts/aoc2015/day14/puzzle1.ts | 57 +++++++++++++++-------------- scripts/aoc2015/day14/utils.ts | 63 ++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 28 deletions(-) diff --git a/scripts/aoc2015/day14/puzzle1.ts b/scripts/aoc2015/day14/puzzle1.ts index 352d1b7..e85cdf9 100644 --- a/scripts/aoc2015/day14/puzzle1.ts +++ b/scripts/aoc2015/day14/puzzle1.ts @@ -17,37 +17,38 @@ Given the descriptions of each reindeer (in your puzzle input), after exactly 25 ALGORITHM: -read input file -init all reindeer's -Lets have a board with each reindeer (check class) - -After each second, we should "tick" on reindeer What distance has reindeer traveled after 2503 seconds? What distance has winning reindeer traveled? - What is the max distance on the board? -========== -// Reindeer - class -fly speed (km/s) -fly limit (s) -rest limit (s) -currentActivity: Flying/Resting -timeSpentOnActivity (s) -distanceTraveled: (km) - -methods: -tick() --if currentActivity is FLying - update distance traveled - increment time spent on Activity ++1 - if time spent on activity is equal to fly limit, - switch to resting activity - set time spent on Activity to 0 -else currentActivity is Resting - increment time spent on Activity ++1 - if time spent on activity is equal to rest limit, - switch to flying activity - set time spent on Activity to 0 -========== */ + +import { parseReindeerLine, Reindeer } from "./utils.ts"; + +async function processFile(filename: string, finalTime: number): Promise { + // read input file + const input = await Deno.readTextFile(filename); + // Lets have a board with each reindeer (check class) + const board: Reindeer[] = []; + // init all reindeer's + // + for (const line of input.split("\n")) { + const data = parseReindeerLine(line); + if (data) { + board.push(new Reindeer(data)); + } + } + // After each second, we should "tick" on reindeer + for (let i = 0; i <= finalTime; i++) { + for (const reindeer of board) { + reindeer.tick(); + } + } + console.log( + "max distance", + Math.max(...board.map((reindeer) => reindeer.distanceTraveled)), + ); +} + +processFile("simpleInput.txt", 1000); diff --git a/scripts/aoc2015/day14/utils.ts b/scripts/aoc2015/day14/utils.ts index 56bab76..36ad36f 100644 --- a/scripts/aoc2015/day14/utils.ts +++ b/scripts/aoc2015/day14/utils.ts @@ -18,3 +18,66 @@ export function parseReindeerLine(line: string): { restLimit: parseInt(match[4], 10), }; } + +export enum ReindeerActivity { + Flying, + Resting, +} + +export class Reindeer { + name: string; + // fly speed (km/s) + speed: number; + // fly limit (s) + flyLimit: number; + // rest limit (s) + restLimit: number; + // currentActivity: Flying/Resting + currentActivity: ReindeerActivity; + // timeSpentOnActivity (s) + timeSpentOnActivity: number; + // distanceTraveled: (km) + distanceTraveled: number; + constructor({ name, speed, restLimit, flyLimit }: { + name: string; + speed: number; + restLimit: number; + flyLimit: number; + }) { + this.name = name; + this.speed = speed; + this.flyLimit = flyLimit; + this.restLimit = restLimit; + this.currentActivity = ReindeerActivity.Flying; + this.timeSpentOnActivity = 0; + this.distanceTraveled = 0; + } + + /* + */ + tick(): void { + // increment time spent on Activity ++1 + this.timeSpentOnActivity++; + // -if currentActivity is FLying + if (this.currentActivity === ReindeerActivity.Flying) { + // update distance traveled + this.distanceTraveled = this.distanceTraveled + this.speed; + // if time spent on activity is equal to fly limit, + if (this.timeSpentOnActivity >= this.flyLimit) { + // switch to resting activity + this.currentActivity = ReindeerActivity.Resting; + // set time spent on Activity to 0 + this.timeSpentOnActivity = 0; + } + // else currentActivity is Resting + } else { + // if time spent on activity is equal to rest limit, + if (this.timeSpentOnActivity >= this.restLimit) { + // switch to flying activity + this.currentActivity = ReindeerActivity.Flying; + // set time spent on Activity to 0 + this.timeSpentOnActivity = 0; + } + } + } +} From ec47d3f0075cc248c29e17ed581124942853558b Mon Sep 17 00:00:00 2001 From: lukasbicus Date: Wed, 25 Sep 2024 12:13:32 +0200 Subject: [PATCH 06/10] Add tests for Reindeer class --- scripts/aoc2015/day14/utils.test.ts | 61 ++++++++++++++++++++++++++++- scripts/aoc2015/day14/utils.ts | 8 ++-- 2 files changed, 63 insertions(+), 6 deletions(-) diff --git a/scripts/aoc2015/day14/utils.test.ts b/scripts/aoc2015/day14/utils.test.ts index 75b0b07..a184545 100644 --- a/scripts/aoc2015/day14/utils.test.ts +++ b/scripts/aoc2015/day14/utils.test.ts @@ -1,6 +1,6 @@ import { assertEquals } from "@std/assert"; -import { describe, it } from "@std/testing/bdd"; -import { parseReindeerLine } from "./utils.ts"; +import { beforeEach, describe, it } from "@std/testing/bdd"; +import { parseReindeerLine, Reindeer, ReindeerActivity } from "./utils.ts"; describe("parseReindeerLine", function () { it("should return null for invalid line", function () { @@ -20,3 +20,60 @@ describe("parseReindeerLine", function () { ); }); }); + +describe("Reindeer", function () { + let reindeer: Reindeer; + beforeEach(function () { + reindeer = new Reindeer({ + name: "Dancer", + speed: 16, + flyLimit: 11, + restLimit: 162, + }); + }); + + // After one second Dancer has gone 16 km. + it("After one second Dancer has gone 16 km.", function () { + reindeer.tick(); + assertEquals(reindeer.currentActivity, ReindeerActivity.Flying); + assertEquals(reindeer.distanceTraveled, 16); + assertEquals(reindeer.timeSpentOnActivity, 1); + }); + // After ten seconds Dancer has gone 160 km. + it("After 10 seconds Dancer has gone 160 km.", function () { + for (let i = 0; i < 10; i++) { + reindeer.tick(); + } + assertEquals(reindeer.currentActivity, ReindeerActivity.Flying); + assertEquals(reindeer.distanceTraveled, 160); + assertEquals(reindeer.timeSpentOnActivity, 10); + }); + // On the eleventh second Dancer continues on for a total distance of 176 km. + + it("After 11 seconds Dancer has gone 176 km.", function () { + for (let i = 0; i < 11; i++) { + reindeer.tick(); + } + assertEquals(reindeer.currentActivity, ReindeerActivity.Resting); + assertEquals(reindeer.distanceTraveled, 176); + assertEquals(reindeer.timeSpentOnActivity, 0); + }); + // On the 12th second Dancer stays at 176 + it("After 12 seconds Dancer has gone 176 km.", function () { + for (let i = 0; i < 12; i++) { + reindeer.tick(); + } + assertEquals(reindeer.currentActivity, ReindeerActivity.Resting); + assertEquals(reindeer.distanceTraveled, 176); + assertEquals(reindeer.timeSpentOnActivity, 1); + }); + it("After 174 seconds Dancer has gone 192 km.", function () { + for (let i = 0; i < 174; i++) { + reindeer.tick(); + } + assertEquals(reindeer.currentActivity, ReindeerActivity.Flying); + assertEquals(reindeer.distanceTraveled, 192); + assertEquals(reindeer.timeSpentOnActivity, 1); + }); + // On the 174th second, Dancer distance is 176 + 16. +}); diff --git a/scripts/aoc2015/day14/utils.ts b/scripts/aoc2015/day14/utils.ts index 36ad36f..7f2ba89 100644 --- a/scripts/aoc2015/day14/utils.ts +++ b/scripts/aoc2015/day14/utils.ts @@ -25,13 +25,13 @@ export enum ReindeerActivity { } export class Reindeer { - name: string; + private name: string; // fly speed (km/s) - speed: number; + private speed: number; // fly limit (s) - flyLimit: number; + private flyLimit: number; // rest limit (s) - restLimit: number; + private restLimit: number; // currentActivity: Flying/Resting currentActivity: ReindeerActivity; // timeSpentOnActivity (s) From d0aa0a72b96021a1ad2b386719bc0bfce3113352 Mon Sep 17 00:00:00 2001 From: lukasbicus Date: Wed, 25 Sep 2024 12:13:39 +0200 Subject: [PATCH 07/10] Solve puzzle1 --- scripts/aoc2015/day14/puzzle1.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/aoc2015/day14/puzzle1.ts b/scripts/aoc2015/day14/puzzle1.ts index e85cdf9..02de162 100644 --- a/scripts/aoc2015/day14/puzzle1.ts +++ b/scripts/aoc2015/day14/puzzle1.ts @@ -40,7 +40,7 @@ async function processFile(filename: string, finalTime: number): Promise { } } // After each second, we should "tick" on reindeer - for (let i = 0; i <= finalTime; i++) { + for (let i = 0; i < finalTime; i++) { for (const reindeer of board) { reindeer.tick(); } @@ -52,3 +52,5 @@ async function processFile(filename: string, finalTime: number): Promise { } processFile("simpleInput.txt", 1000); + +processFile("input.txt", 2503); From 5c4b3053802a77a0fbfb55c366cfca4876021cb2 Mon Sep 17 00:00:00 2001 From: lukasbicus Date: Wed, 25 Sep 2024 12:17:40 +0200 Subject: [PATCH 08/10] Add puzzle2 --- scripts/aoc2015/day14/puzzle2.ts | 66 ++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 scripts/aoc2015/day14/puzzle2.ts diff --git a/scripts/aoc2015/day14/puzzle2.ts b/scripts/aoc2015/day14/puzzle2.ts new file mode 100644 index 0000000..ea7498a --- /dev/null +++ b/scripts/aoc2015/day14/puzzle2.ts @@ -0,0 +1,66 @@ +/* +--- Day 14: Reindeer Olympics --- +This year is the Reindeer Olympics! Reindeer can fly at high speeds, but must rest occasionally to recover their energy. Santa would like to know which of his reindeer is fastest, and so he has them race. + +Reindeer can only either be flying (always at their top speed) or resting (not moving at all), and always spend whole seconds in either state. + +For example, suppose you have the following Reindeer: + +Comet can fly 14 km/s for 10 seconds, but then must rest for 127 seconds. +Dancer can fly 16 km/s for 11 seconds, but then must rest for 162 seconds. +After one second, Comet has gone 14 km, while Dancer has gone 16 km. After ten seconds, Comet has gone 140 km, while Dancer has gone 160 km. On the eleventh second, Comet begins resting (staying at 140 km), and Dancer continues on for a total distance of 176 km. On the 12th second, both reindeer are resting. They continue to rest until the 138th second, when Comet flies for another ten seconds. On the 174th second, Dancer flies for another 11 seconds. + +In this example, after the 1000th second, both reindeer are resting, and Comet is in the lead at 1120 km (poor Dancer has only gotten 1056 km by that point). So, in this situation, Comet would win (if the race ended at 1000 seconds). + +Given the descriptions of each reindeer (in your puzzle input), after exactly 2503 seconds, what distance has the winning reindeer traveled? + +--- Part Two --- +Seeing how reindeer move in bursts, Santa decides he's not pleased with the old scoring system. + +Instead, at the end of each second, he awards one point to the reindeer currently in the lead. (If there are multiple reindeer tied for the lead, they each get one point.) He keeps the traditional 2503 second time limit, of course, as doing otherwise would be entirely ridiculous. + +Given the example reindeer from above, after the first second, Dancer is in the lead and gets one point. He stays in the lead until several seconds into Comet's second burst: after the 140th second, Comet pulls into the lead and gets his first point. Of course, since Dancer had been in the lead for the 139 seconds before that, he has accumulated 139 points by the 140th second. + +After the 1000th second, Dancer has accumulated 689 points, while poor Comet, our old champion, only has 312. So, with the new scoring system, Dancer would win (if the race ended at 1000 seconds). + +Again given the descriptions of each reindeer (in your puzzle input), after exactly 2503 seconds, how many points does the winning reindeer have? + +ALGORITHM: + +after each second +tick on board +find currentWinningDistance on the board +award reindeers with winning distances with one point + + */ + +import { parseReindeerLine, Reindeer } from "./utils.ts"; + +async function processFile(filename: string, finalTime: number): Promise { + // read input file + const input = await Deno.readTextFile(filename); + // Lets have a board with each reindeer (check class) + const board: Reindeer[] = []; + // init all reindeer's + // + for (const line of input.split("\n")) { + const data = parseReindeerLine(line); + if (data) { + board.push(new Reindeer(data)); + } + } + // After each second, we should "tick" on reindeer + for (let i = 0; i < finalTime; i++) { + for (const reindeer of board) { + reindeer.tick(); + } + } + console.log( + "max distance", + Math.max(...board.map((reindeer) => reindeer.distanceTraveled)), + ); +} + +processFile("simpleInput.txt", 1000); + +processFile("input.txt", 2503); From 5e7de2e9ae0001cb62c297be4489e396179b1b34 Mon Sep 17 00:00:00 2001 From: lukasbicus Date: Wed, 25 Sep 2024 12:21:17 +0200 Subject: [PATCH 09/10] Solve puzzle2 --- scripts/aoc2015/day14/puzzle2.ts | 17 +++++++++++++++-- scripts/aoc2015/day14/utils.ts | 8 ++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/scripts/aoc2015/day14/puzzle2.ts b/scripts/aoc2015/day14/puzzle2.ts index ea7498a..ee2ea8e 100644 --- a/scripts/aoc2015/day14/puzzle2.ts +++ b/scripts/aoc2015/day14/puzzle2.ts @@ -54,10 +54,23 @@ async function processFile(filename: string, finalTime: number): Promise { for (const reindeer of board) { reindeer.tick(); } + // find max distance + const maxDistance = Math.max( + ...board.map((reindeer) => reindeer.distanceTraveled), + ); + // award each dear with travelDistance equal to max distance + for ( + const reindeer of board.filter((reindeer) => + reindeer.distanceTraveled === maxDistance + ) + ) { + reindeer.addPoint(); + } } + console.log( - "max distance", - Math.max(...board.map((reindeer) => reindeer.distanceTraveled)), + "max points", + Math.max(...board.map((reindeer) => reindeer.points)), ); } diff --git a/scripts/aoc2015/day14/utils.ts b/scripts/aoc2015/day14/utils.ts index 7f2ba89..f2ac49d 100644 --- a/scripts/aoc2015/day14/utils.ts +++ b/scripts/aoc2015/day14/utils.ts @@ -38,6 +38,7 @@ export class Reindeer { timeSpentOnActivity: number; // distanceTraveled: (km) distanceTraveled: number; + points: number; constructor({ name, speed, restLimit, flyLimit }: { name: string; speed: number; @@ -51,10 +52,9 @@ export class Reindeer { this.currentActivity = ReindeerActivity.Flying; this.timeSpentOnActivity = 0; this.distanceTraveled = 0; + this.points = 0; } - /* - */ tick(): void { // increment time spent on Activity ++1 this.timeSpentOnActivity++; @@ -80,4 +80,8 @@ export class Reindeer { } } } + + addPoint(): void { + this.points++; + } } From 043110787b9bac93a070500abe160d1eba612e9b Mon Sep 17 00:00:00 2001 From: lukasbicus Date: Wed, 25 Sep 2024 12:23:37 +0200 Subject: [PATCH 10/10] Clean comments in tests. --- scripts/aoc2015/day14/utils.test.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/scripts/aoc2015/day14/utils.test.ts b/scripts/aoc2015/day14/utils.test.ts index a184545..860112d 100644 --- a/scripts/aoc2015/day14/utils.test.ts +++ b/scripts/aoc2015/day14/utils.test.ts @@ -32,14 +32,12 @@ describe("Reindeer", function () { }); }); - // After one second Dancer has gone 16 km. it("After one second Dancer has gone 16 km.", function () { reindeer.tick(); assertEquals(reindeer.currentActivity, ReindeerActivity.Flying); assertEquals(reindeer.distanceTraveled, 16); assertEquals(reindeer.timeSpentOnActivity, 1); }); - // After ten seconds Dancer has gone 160 km. it("After 10 seconds Dancer has gone 160 km.", function () { for (let i = 0; i < 10; i++) { reindeer.tick(); @@ -48,7 +46,6 @@ describe("Reindeer", function () { assertEquals(reindeer.distanceTraveled, 160); assertEquals(reindeer.timeSpentOnActivity, 10); }); - // On the eleventh second Dancer continues on for a total distance of 176 km. it("After 11 seconds Dancer has gone 176 km.", function () { for (let i = 0; i < 11; i++) { @@ -58,7 +55,6 @@ describe("Reindeer", function () { assertEquals(reindeer.distanceTraveled, 176); assertEquals(reindeer.timeSpentOnActivity, 0); }); - // On the 12th second Dancer stays at 176 it("After 12 seconds Dancer has gone 176 km.", function () { for (let i = 0; i < 12; i++) { reindeer.tick(); @@ -75,5 +71,4 @@ describe("Reindeer", function () { assertEquals(reindeer.distanceTraveled, 192); assertEquals(reindeer.timeSpentOnActivity, 1); }); - // On the 174th second, Dancer distance is 176 + 16. });