Skip to content

Commit bd423da

Browse files
committed
Day 12.
1 parent 772366a commit bd423da

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

2024/day-12.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import { Expect, Equal } from "../test";
2323
*
2424
* Help 🎩Bernard before 🎅Santa continues his violent tirade.
2525
*
26+
* Help 🎩Bernard before 🎅Santa continues his violent tirade. He's not about to spend a bunch of time looking at each child so instead he's just deciding whether a child is naughty or nice based on the number of characters in their name!
27+
*
2628
* A HUGE hint
2729
*
2830
* Part of the fun/trick of this challenge is that you can't solve it normally by iterating because you'll get:
@@ -84,14 +86,14 @@ type NaughtyOrNice = {
8486
};
8587

8688
type FormatNames<T extends string[][]> = {
87-
[I in keyof T]: T[I] extends [infer Name extends string, infer Rating extends string, infer Count extends string]
89+
[K in keyof T]: T[K] extends [infer Name extends string, string, infer Count extends string]
8890
? {
8991
name: Name;
9092
count: Count extends `${infer CountNum extends number}` ? CountNum : never;
9193
rating: NaughtyOrNice[Name & keyof NaughtyOrNice];
9294
}
9395
: never;
94-
} & { length: T["length"] };
96+
};
9597

9698
// *************************************************************************************
9799
// *** Tests ***

0 commit comments

Comments
 (0)