diff --git a/advent-of-typescript/2023/day_18.ts b/advent-of-typescript/2023/day_18.ts new file mode 100644 index 0000000..afedf15 --- /dev/null +++ b/advent-of-typescript/2023/day_18.ts @@ -0,0 +1,140 @@ +import { Equal, Expect } from "type-testing"; + +import { Increment } from "@/utils/type-helpers"; + +/* ----------------------------------------------------------------------------------------------- + * Code here + * -----------------------------------------------------------------------------------------------*/ + +type Count = T extends [infer S, ...infer R] + ? S extends E // if the current element is the element we're counting + ? Count> // increment the count and recurse + : Count // otherwise, recurse for the rest of the array without incrementing + : C["length"]; // if we've reached the end of the array, return the count + +/* ----------------------------------------------------------------------------------------------- + * Do not edit below this line + * -----------------------------------------------------------------------------------------------*/ + +type ToySack = [ + "๐ŸŽธ", + "๐ŸŽง", + "๐Ÿ‘Ÿ", + "๐Ÿ‘Ÿ", + "๐Ÿ’ป", + "๐Ÿช€", + "๐Ÿงฉ", + "๐ŸŽฎ", + "๐ŸŽจ", + "๐Ÿ•น๏ธ", + "๐Ÿ“ฑ", + "๐Ÿงฉ", + "๐Ÿงธ", + "๐ŸŽง", + "๐Ÿ‘Ÿ", + "๐Ÿšฒ", + "๐Ÿ“š", + "โŒš", + "๐ŸŽจ", + "๐Ÿ‘Ÿ", + "๐ŸŽธ", + "๐Ÿงธ", + "๐Ÿ‘Ÿ", + "๐ŸŽธ", + "๐Ÿ“ฑ", + "๐ŸŽง", + "๐ŸŽฎ", + "๐ŸŽ’", + "๐Ÿ“ฑ", + "๐Ÿงฉ", + "๐Ÿงฉ", + "๐Ÿšฒ", + "๐Ÿ•น๏ธ", + "๐Ÿงต", + "๐Ÿ“ฑ", + "๐Ÿ•น๏ธ", + "๐Ÿ•ฐ๏ธ", + "๐Ÿงข", + "๐Ÿ•น๏ธ", + "๐Ÿ‘Ÿ", + "๐Ÿงธ", + "๐Ÿ“š", + "๐Ÿง", + "๐Ÿงฉ", + "๐ŸŽธ", + "๐ŸŽฎ", + "๐Ÿง", + "๐Ÿ“š", + "๐Ÿ’ป", + "โŒš", + "๐Ÿ›น", + "๐Ÿง", + "๐Ÿงฃ", + "๐Ÿช", + "๐ŸŽธ", + "๐Ÿงธ", + "๐Ÿงธ", + "๐Ÿงธ", + "๐Ÿงฉ", + "๐Ÿช", + "๐ŸŽ๏ธ", + "๐ŸŽ๏ธ", + "๐Ÿง", + "๐Ÿ“š", + "๐Ÿงธ", + "๐Ÿ•ถ๏ธ", + "๐Ÿ’ป", + "โŒš", + "โŒš", + "๐Ÿ•ถ๏ธ", + "๐ŸŽง", + "๐ŸŽง", + "๐ŸŽง", + "๐Ÿ’ป", + "๐Ÿ‘Ÿ", + "๐ŸŽธ", + "๐Ÿ’ป", + "๐Ÿช", + "๐Ÿ“š", + "๐ŸŽจ", + "๐Ÿ“ฑ", + "๐ŸŽง", + "๐Ÿ“ฑ", + "๐ŸŽธ", + "๐ŸŽ๏ธ", + "๐Ÿ‘Ÿ", + "๐Ÿšฒ", + "๐Ÿ“ฑ", + "๐Ÿšฒ", + "๐ŸŽธ", +]; + +type test_0_actual = Count; +// ^? +type test_0_expected = 8; +type test_0 = Expect>; + +type test_1_actual = Count; +// ^? +type test_1_expected = 0; +type test_1 = Expect>; + +type test_2_actual = Count; +// ^? +type test_2_expected = 6; +type test_2 = Expect>; + +type test_3_actual = Count; +// ^? +type test_3_expected = 1; +type test_3 = Expect>; + +type test_4_actual = Count; +// ^? +type test_4_expected = 3; +type test_4 = Expect>; + +type test_5_actual = Count; +// ^? +type test_5_expected = 5; +type test_5 = Expect>;