Skip to content

Commit

Permalink
feat: solved day 13 type challenge
Browse files Browse the repository at this point in the history
Signed-off-by: rajput-hemant <rajput.hemant2001@gmail.com>
  • Loading branch information
rajput-hemant committed Dec 15, 2023
1 parent e8c99aa commit b843d09
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
12 changes: 12 additions & 0 deletions advent-of-typescript/2023/day_01.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Equal, Expect } from "type-testing";

type test_0_actual = SantasFavoriteCookies;
// ^?
type test_0_expected = "ginger-bread" | "chocolate-chip";
type test_0 = Expect<Equal<test_0_actual, test_0_expected>>;

/* -----------------------------------------------------------------------------------------------
* Code Here
* -----------------------------------------------------------------------------------------------*/

type SantasFavoriteCookies = "ginger-bread" | "chocolate-chip";
File renamed without changes.
Empty file removed advent-of-typescript/2023/day_1.ts
Empty file.
57 changes: 57 additions & 0 deletions advent-of-typescript/2023/day_13.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { Equal, Expect } from "type-testing";

import { Increment } from "@/utils/type-helpers";

/* -----------------------------------------------------------------------------------------------
* Code Here
* -----------------------------------------------------------------------------------------------*/

type DayCounter<
S extends number,
E extends number,
I extends any[] = [any],
> = S extends E
? E // if start is equal to end, return end
: S | DayCounter<Increment<I>["length"], E, Increment<I>>;
// otherwise, union start with the result of incrementing start by 1, and recurse

/* -----------------------------------------------------------------------------------------------
* Do Not Edit Below This Line
* -----------------------------------------------------------------------------------------------*/

type TwelveDaysOfChristmas = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
type test_0_actual = DayCounter<1, 12>;
// ^?
type test_0_expected = TwelveDaysOfChristmas;
type test_0 = Expect<Equal<test_0_expected, test_0_actual>>;

type DaysUntilChristmas =
| 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;
type test_1_actual = DayCounter<1, 25>;
// ^?
type test_1_expected = DaysUntilChristmas;
type test_1 = Expect<Equal<test_1_expected, test_1_actual>>;

0 comments on commit b843d09

Please sign in to comment.