Skip to content

Instantly share code, notes, and snippets.

@civilizeddev
Created September 4, 2019 12:37
Show Gist options
  • Save civilizeddev/7b4bf497b33be5d6dbb1b37b786cc561 to your computer and use it in GitHub Desktop.
Save civilizeddev/7b4bf497b33be5d6dbb1b37b786cc561 to your computer and use it in GitHub Desktop.
배열 조합
export function combination<T>(xs: T[]): Array<Array<T>> {
return Array.from({ length: 2 ** xs.length }).map((_, i) =>
xs.filter((_, j) => (i >>> j) & 1)
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment