Type Challenges Judge

MinusOne

提出詳細

type TupleOfLength<N extends number, Tuple extends any[] = []> = Tuple['length'] extends N ? Tuple : TupleOfLength<N, [...Tuple, 0]> type MinusOne<T extends number> = TupleOfLength<T> extends [infer _, ...infer Rest] ? Rest['length'] : never;
提出日時2023-08-12 12:47:08
問題MinusOne
ユーザーtekihei2317
ステータスWrong Answer
テストケース
import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect<Equal<MinusOne<1>, 0>>, Expect<Equal<MinusOne<55>, 54>>, Expect<Equal<MinusOne<3>, 2>>, Expect<Equal<MinusOne<100>, 99>>, Expect<Equal<MinusOne<1101>, 1100>>, ]