-
Notifications
You must be signed in to change notification settings - Fork 6
/
README
77 lines (49 loc) · 2.63 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
==================================================================================
Combinatorics library for the Processings
This library provides an easy way to generate combinations, variations and
permutations from a given set of values.
----------------------------------------------------------------------------------
Current release is now compatible with JavaScript mode in Processing 2.0
----------------------------------------------------------------------------------
Please use the zip under Downloads until Processing 2.0 has been released.
https://github.com/downloads/fjenett/combinatorics/Combinatorics.zip
==================================================================================
What?
Combinatorics library provides iterators for these combinatorical sets:
– Combinations
– CombinationSets
– Variations
– VariationSets
– Permutations
The iterators provide arrays of indices (addresses) into an imaginary
array of a given length at each step. These adresses can then be used
on any kind of real array. Example needed, so ..
Say you have a String array:
{ "A", "B", "C" }
... and you'd like to find all possible combinations at any length.
A CombinationSet would return these indice arrays:
[] empty (0 elements)
[0], [1], [2] combinations of 1 element
[0, 1], [0, 2], [1, 2] combinations of 2 elements
[0, 1, 2] combinations of 3 elements
Using these indices to read from your array would give you:
(null)
["A"], ["B"], ["C"]
["A", "B"], ["A", "C"], ["B", "C"]
["A", "B", "C"]
----------------------------------------------------------------------------------
A quick class overview:
Combination unique combinations, no duplications, order is ignored
CombinationSet range of combinations at different lengths
Variation all possible variations, includes duplication, order matters
VariationSet range of variations at different lengths
Permutation all possible ways to order the elements, no duplications
==================================================================================
Props, Thank-you's
The Java (and JavaScript) code for permutation is based on code by Michael Gillelands
(at http://www.merriampark.com/perm.htm), which he claims to be an implementation of
Kenneth H. Rosen, Discrete Mathematics and Its Applications,
2nd edition (NY: McGraw-Hill, 1991), pp. 282-284
BigInteger (in JavaScript version) was written by John Tobey and Matthew Crumley
and is available at http://silentmatt.com/biginteger/ and
https://github.com/jtobey/javascript-bignum