MinusOne
提出詳細
type TupleOfLengthInner<N extends string, Tuple extends any[] = []> = `${Tuple['length']}` extends N ? Tuple : TupleOfLengthInner<N, [...Tuple, 0]> type TupleOfLength<N extends string, T extends any[] = []> = N extends `${infer First}${infer Rest}` ? TupleOfLength<Rest, [...T, ...T, ...T, ...T, ...T, ...T, ...T, ...T, ...T, ...T, ...TupleOfLengthInner<First>]> : T; type MinusOne<T extends number> = TupleOfLength<`${T}`> extends [infer _, ...infer Rest] ? Rest['length'] : never;
提出日時 | 2023-08-12 13:09:50 |
---|---|
問題 | MinusOne |
ユーザー | tekihei2317 |
ステータス | Accepted |
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>>, ]