Combinatorics

◷ Reading Time: 4 minutes

FlexRule.Extensions.Combinatorics

Calculates different arrangements of a set. for more information about the math behind check this paper.

Let’s say we have the following list:

permutations

Permutations are arrangements of objects (with or without repetition), the order does matter

 permutations (list, repeat)

  • Sample: A = [a,b,c]
  • permutations(A,true)
  • Result:
123
abc
acb
bac
bca
cab
cba

combinations

Combinations are selections of objects, with or without repetition, the order does not matter.

 combinations (list, number, repeat)

  • Sample: A = [a,b,c]
  • combinations(A, 2, true)
  • Result:
12
aa
ab
ac
bb
bc
cc

  • combination(A, 2, false)
  • Result:
12
ab
ac
bc

variations

Variations are arrangements of selections of objects, where the order of the selected objects matters.

 variations (list, number, repeat)
  • Sample: A=[a,b,c]
  • variations(A, 2,true)
  • Result:
12
aa
ab
ac
ba
bb
bc
ca
cb
cc

  • variations(A, 2, false)
  • Result:
12
ab
ac
ba
ca
bc
cb

Updated on October 19, 2022

Was this article helpful?

Related Articles