Skip to content

colt-browning/compositions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Generating integer compositions.

By default, the compositions of each integer are listed in the lexicographic order.

Command line arguments (all of them are optional):

  • an integer number n: get the compositions for the numbers from 0 to n (the default is 6);
  • colex: reverse each composition after ordering (i. e., use the colexicographic order instead);
  • reverse: reverse the lexicographic ordering;
  • len+/len-: group the compositions by length and order the groups by increasing/decreasing length;
  • -1: subtract 1 from each term (this allows listing all tuples of nonnegative integers);
  • flat: instead of pretty formatting, output all terms in one line, like in the OEIS.

On Windows, compile with --features clip to put the "flat" output to the clipboard. This adds dependencies.

The pretty output of cargo run 4 looks like this:

[[]]
[[1]]
[[1, 1], [2]]
[[1, 1, 1], [1, 2], [2, 1], [3]]
[[1, 1, 1, 1], [1, 1, 2], [1, 2, 1], [1, 3], [2, 1, 1], [2, 2], [3, 1], [4]]

OEIS sequences for the compositions and the corresponding command line arguments:

The content of this repository is licensed under Apache License 2.0 or CC BY 4.0 at your option.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages