Skip to content

bobg/combo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Combo - combinatorial operations for Go

Go Reference Go Report Card Tests Coverage Status Mentioned in Awesome Go

This is combo, a library of combinatorial operations for Go. Given a slice, it can compute its permutations, its n-element combinations, and its n-element combinations-with-replacement.

There is also a command-line tool for invoking these operations on a list of strings.

Installation and usage

For library usage, please see the documentation at pkg.go.dev.

Installing the command-line tool:

go install github.com/bobg/combo/cmd/combo@latest

Usage:

combo perm [ARG ARG ...]
combo comb N [ARG ARG ...]
combo rcomb N [ARG ARG ...]

The first argument is the operation to run: perm for permutations; comb for combinations; and rcomb for combinations-with-replacement.

The comb and rcomb subcommands require a numeric argument, N, the number of strings to choose in each combination.

The input is specified as additional arguments on the command line. If no such arguments are supplied, then the input is read from standard input, one line per string.

Examples:

$ combo perm 1 2 3
1 2 3
2 1 3
3 1 2
1 3 2
2 3 1
3 2 1
$ combo comb 2 a b c
a b
a c
b c
$ combo rcomb 2 a b c
a a
a b
a c
b b
b c
c c

About

Combinatorial operations for Go

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages