From 0f40a098d0c23ae073f6aa63fc8804a42218fada Mon Sep 17 00:00:00 2001 From: lukasbicus Date: Tue, 1 Oct 2024 08:33:36 +0200 Subject: [PATCH] Fix checkSue2 --- scripts/aoc2015/day16/utils.test.ts | 12 ++++++------ scripts/aoc2015/day16/utils.ts | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/aoc2015/day16/utils.test.ts b/scripts/aoc2015/day16/utils.test.ts index 4d2be22..70172da 100644 --- a/scripts/aoc2015/day16/utils.test.ts +++ b/scripts/aoc2015/day16/utils.test.ts @@ -53,7 +53,7 @@ describe("checkSue", function () { false, ); }); - it("should return false when there is no match", function () { + it("should return true when there is match", function () { assertEquals( checkSue({ name: "Sue X", @@ -84,19 +84,19 @@ describe("checkSue2", function () { assertEquals( checkSue2({ name: "Sue 8", - pomeranians: 7, - goldfish: 8, - cars: 10, + pomeranians: 3, + cats: 7, + trees: 3, }, referenceSue), false, ); }); - it("should return false when there is no match", function () { + it("should return true when there is match", function () { assertEquals( checkSue2({ name: "Sue X", - trees: 5, cats: 8, + trees: 4, cars: 2, pomeranians: 2, goldfish: 4, diff --git a/scripts/aoc2015/day16/utils.ts b/scripts/aoc2015/day16/utils.ts index d222a66..038204e 100644 --- a/scripts/aoc2015/day16/utils.ts +++ b/scripts/aoc2015/day16/utils.ts @@ -99,13 +99,13 @@ export function checkSue2(sue: Partial, referenceSue: Sue): boolean { switch (name) { case "pomeranians": case "goldfish": - if (referenceSue[name] < value) { + if (referenceSue[name] <= value) { return false; } break; case "cats": case "trees": - if (referenceSue[name] > value) { + if (referenceSue[name] >= value) { return false; } break;