forked from type-challenges/type-challenges
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(question): add type-challenges#8767 - Permuatation & Combination (…
…type-challenges#8768) Co-authored-by: Homyee King <[email protected]>
- Loading branch information
1 parent
1fb6132
commit 72fa484
Showing
4 changed files
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Give an array of strings, then do Permutation & Combination. | ||
It's also useful for the prop types like video [controlsList](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/controlsList) | ||
|
||
```ts | ||
// expected to be `"foo" | "bar" | "baz" | "foo bar baz" | "bar foo" | "baz foo" | "bar baz" | "baz bar"` | ||
type Keys = PermutationCombination<['foo', 'bar', 'baz']> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
difficulty: meduim | ||
title: Permuatation & Combination | ||
tags: array, application, string | ||
author: | ||
github: HomyeeKing | ||
name: Homyee King | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
type PermutationCombination<T extends string[]> = any |
6 changes: 6 additions & 0 deletions
6
questions/8767-meduim-permuatation-and-combination/test-cases.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { Equal, Expect } from '@type-challenges/utils' | ||
|
||
type cases = [ | ||
Expect<Equal<PermutationCombination<['foo', 'bar', 'baz']>, | ||
'foo' | 'bar' | 'baz' | 'foo bar baz' | 'bar foo' | 'baz foo' | 'bar baz' | 'baz bar'>>, | ||
] |