• Stars
    star
    113
  • Rank 310,115 (Top 7 %)
  • Language
    Go
  • License
    MIT License
  • Created over 6 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Golang library which provide an algorithm to generate all combinations out of a given string array.

Golang combinations

GoDoc Go Coverage Status Go Report Card License

This package provides a method to generate all ordered combinations out of a given string array. This essentially creates the powerset of the given array except that the empty set is disregarded.

Examples

Take a look at the godoc for examples.

In general when you have e.g. []string{"A", "B", "C"} you will get:

[
    ["A"],
    ["B"],
    ["A", "B"],
    ["C"],
    ["A", "C"],
    ["B", "C"],
    ["A", "B", "C"]
]

Background

The algorithm iterates over each number from 1 to 2^length(input), separating it by binary components and utilizes the true/false interpretation of binary 1's and 0's to extract all unique ordered combinations of the input slice.

E.g. a binary number 0011 means selecting the first and second index from the slice and ignoring the third and fourth. For input {"A", "B", "C", "D"} this signifies the combination {"A", "B"}.

For input slice {"A", "B", "C", "D"} there are 2^4 - 1 = 15 binary combinations, so mapping each bit position to a slice index and selecting the entry for binary 1 and discarding for binary 0 gives the full subset as:

1	=	0001	=>	---A	=>	{"A"}
2	=	0010	=>	--B-	=>	{"B"}
3	=	0011	=>	--BA	=>	{"A", "B"}
4	=	0100	=>	-C--	=>	{"C"}
5	=	0101	=>	-C-A	=>	{"A", "C"}
6	=	0110	=>	-CB-	=>	{"B", "C"}
7	=	0111	=>	-CBA	=>	{"A", "B", "C"}
8	=	1000	=>	D---	=>	{"D"}
9	=	1001	=>	D--A	=>	{"A", "D"}
10	=	1010	=>	D-B-	=>	{"B", "D"}
11	=	1011	=>	D-BA	=>	{"A", "B", "D"}
12	=	1100	=>	DC--	=>	{"C", "D"}
13	=	1101	=>	DC-A	=>	{"A", "C", "D"}
14	=	1110	=>	DCB-	=>	{"B", "C", "D"}
15	=	1111	=>	DCBA	=>	{"A", "B", "C", "D"}

More Repositories

1

action-tmate

Debug your GitHub Actions via SSH by using tmate to get access to the runner system itself.
JavaScript
2,923
star
2

awesome-playwright

A curated list of awesome tools, utils and projects using Playwright
458
star
3

golang-url-shortener

URL Shortener written in Golang using Bolt DB or Redis. Provides features such as Deletion, Expiration, OAuth and is of course Dockerizable.
Go
283
star
4

try-playwright

Try Playwright lets you execute and share Playwright scripts in your browser to get started with Playwright.
TypeScript
138
star
5

playwright-test-coverage

Playwright Test (@playwright/test) demo to collect coverage information via Istanbul
TypeScript
107
star
6

python-django-playwright

Example how to use Playwright in combination with Django.
Python
22
star
7

react-have-i-been-pwned

React component for: Have I Been Pwned?
JavaScript
14
star
8

pytest-playwright

Pytest plugin to write Playwright tests with ease. Provides fixtures to have a page instance for each individual test and helpful CLI options for headless browsers.
Python
14
star
9

chrome-odata-viewer

Displays UI5 OData network requests and response payload in a beautified clickable way.
JavaScript
13
star
10

YoutubeWebinterface

JavaScript based graphical YouTube Search Webinterface for the SinusBot.
JavaScript
8
star
11

actions-cheat-sheet

GitHub Actions cheat sheet with some common snippets
7
star
12

playwright-windows-containers

Run Playwright inside Windows Docker containers
TypeScript
6
star
13

connect-to-me

Small summary page for relevant social media profiles.
HTML
5
star
14

golang-hetzner-robot-metrics

Hetzner Robot Price statistics and alerting via Prometheus and Grafana.
Go
5
star
15

DotnetConfDemoTest0947

C#
3
star
16

jump-back-to-1970

3
star
17

golang-env-struct

This package does apply if set the environment variable by a given name from the struct tag to the given struct.
Go
3
star
18

declare-fields-class-properties-compatiblity

TypeScript
2
star
19

testpwdev

HTML
2
star
20

golang-tdd-example

Test driven development in Golang based on Martin Fowlers stack example.
Go
2
star
21

playwright-runner-root-cause-demo

This example shows the usage with Testim Root Cause and the playwright-runner project.
TypeScript
2
star
22

playwright-webview2-demo

Using Playwright in JS/TS/Java/.NET/Java to automate a WebView2 control
TypeScript
2
star
23

azure-container-apps-playwright-demo

Azure Container Apps Playwright example.
HTML
2
star
24

azure-dev-day2

TypeScript
2
star
25

dotnet-batch-childprocess-adds-bom

C#
1
star
26

my-awesome-project

TypeScript
1
star
27

razor-playwright-dotnet-example

HTML
1
star
28

mxschmitt

1
star
29

pwreprotest123

TypeScript
1
star
30

firefox-github-actions-container

TypeScript
1
star
31

discord-happy-hour-demo

TypeScript
1
star
32

vscode-postscript

PostScript Language implementation into VS Code
1
star
33

1506

TypeScript
1
star
34

playwright-docs

Generated Playwright documentations via TypeDoc
1
star
35

client-certificates-with-playwright-demo

TypeScript
1
star
36

Playwright_screenshot_traceback

https://github.com/microsoft/playwright/issues/28098
HTML
1
star
37

playwright-jest-example

Example how to use Playwright in combination with Jest.
JavaScript
1
star
38

github-actions-console-chunking

JavaScript
1
star
39

dotfiles

Shell
1
star
40

python-rpi-alarm

Vue.js application with which you can control an alarm clock via your Raspberry PI.
Python
1
star
41

playwright-driver

Centralized Playwright RPC driver
1
star
42

playwright-azure-sharding

TypeScript
1
star
43

playwright-issue-28595

JavaScript
1
star