25270. Transpose
문제 The transpose of a matrix is an operator which flips a matrix over its diagonal; that is, it switches the row and column indices of the matrix A by producing another matrix, often denoted by AT. type Matrix = Transpose ; // expected to be [[1]] type Matrix1 = Transpose ; // expected to be [[1, 3], [2, 4]] type Matrix2 = Transpose ; // expected to be [[1, 4], [2, 5], [3, 6]] cases type cases =..
25170. ReplaceFirst
문제 Implement the type ReplaceFirst which will replace the first occurrence of S in a tuple T with R. If no such S exists in T, the result should be T. cases type cases = [ Expect, Expect, Expect, Expect, Expect, Expect, ] 문제 링크 정답 type ReplaceFirst = T extends [infer T1, ...infer Rest] ? T1 extends S ? [R, ...Rest] : [T1, ...ReplaceFirst] : [] 풀이 조건 T의 요소 중 처음 나오는 S를 R로 교체한 후 T를 반환한다. T에 S가 없는 경..
21220. PermutationsOfTuple
문제 Given a generic tuple type T extends unknown[], write a type which produces all permutations of T as a union. PermutationsOfTuple /** * Should return: * | [1, number, unknown] * | [1, unknown, number] * | [number, 1, unknown] * | [unknown, 1, number] * | [number, unknown, 1] * | [unknown, number ,1] */ cases type cases = [ Expect, Expect, Expect, Expect>, Expect>, ExpectFalse, ] 문제 링크 정답 type..
18142. All
문제 Returns true if all elements of the list are equal to the second parameter passed in, false if there are any mismatches. type Test1 = [1, 1, 1] type Test2 = [1, 1, 2] type Todo = All // should be same as true type Todo2 = All // should be same as false cases type cases = [ Expect, Expect, Expect, Expect, Expect, Expect, Expect, Expect, Expect, Expect, Expect, Expect, Expect, Expect, Expect, ]..