Type Challenges Judge

IsPalindrome

提出詳細

type Reverse<S extends string> = S extends `${infer S1}${infer S2}` ? `${Reverse<S2>}${S1}` : "" type IsPalindromeImpl<S extends string, T extends string=Reverse<S>> = S extends `${infer S1}${infer S2}` ? T extends `${infer T1}${infer T2}` ? S1 extends T1 ? IsPalindromeImpl<S2,T2> : false : never : true type IsPalindrome<T extends string | number> = IsPalindromeImpl<`${T}`>
提出日時2023-09-20 02:52:35
問題IsPalindrome
ユーザーsankantsu
ステータスAccepted
テストケース
import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect<Equal<IsPalindrome<'abc'>, false>>, Expect<Equal<IsPalindrome<'b'>, true>>, Expect<Equal<IsPalindrome<'abca'>, false>>, Expect<Equal<IsPalindrome<121>, true>>, Expect<Equal<IsPalindrome<19260817>, false>>, ]