sum_all_number_combinations 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +31 -1
- data/lib/sum_all_number_combinations/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e1f8e0f98d31ffb815c33896596e96d54f8e898
|
4
|
+
data.tar.gz: 86e45f3707f47bf30177696bd6f9b9b5c9169388
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30e1ad7393c47f161989fc4ba7f5970479bcb1d8b88e9b0d9af3d30288b0ab45a21b656f4c999d13ed6ce6203229c7a0238313e40e57bd28a2b14265e4409c9d
|
7
|
+
data.tar.gz: bcb837914daa5ae4b28b078227d283698ca64134de93fb94dc750a985949af533d70d817efc887328ad5d180bdd2ad837cb41ff1033e540f8995af4ef0144643
|
data/README.md
CHANGED
@@ -21,7 +21,37 @@ Or install it yourself as:
|
|
21
21
|
|
22
22
|
## Usage
|
23
23
|
|
24
|
-
|
24
|
+
Create your instance variable, passing in the array you would like to sum all the combinations of.
|
25
|
+
```ruby
|
26
|
+
sum_of_all = SumAllCombinations.new([1,2,3])
|
27
|
+
```
|
28
|
+
Call the sum method and pass in the optional keyword arguments of remove_duplicates (default is false) and sort (default is true)
|
29
|
+
```ruby
|
30
|
+
sum_of_all.sum(remove_duplicates: false, sort: true)
|
31
|
+
```
|
32
|
+
The attributes available include:
|
33
|
+
```ruby
|
34
|
+
# passed in array
|
35
|
+
@original
|
36
|
+
|
37
|
+
# flattened array. After sum is called flattened will only include the numbers used for calculation, non-numeric objects will be removed
|
38
|
+
@flattened
|
39
|
+
|
40
|
+
# calculated values array, which is the array holding all the numbers calculated from the addition of all of the possible number combinations, after sum is called
|
41
|
+
@calculated_values
|
42
|
+
|
43
|
+
#combinations used array, which is the array holding all the information of how the numbers were combined to determine results
|
44
|
+
@combinations_used
|
45
|
+
```
|
46
|
+
## Example
|
47
|
+
```ruby
|
48
|
+
sum_of_all = SumAllCombinations.new([1,2,[3,4], "house"])
|
49
|
+
sum_of_all.original #=> [1, 2, [3, 4], "house"]
|
50
|
+
sum_of_all.flattened #=> [1, 2, 3, 4, "house"]
|
51
|
+
sum_of_all.sum #=> [3.0, 4.0, 5.0, 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 9.0, 10.0]
|
52
|
+
sum_of_all.calculated_values #=> [3.0, 4.0, 5.0, 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 9.0, 10.0]
|
53
|
+
sum_of_all.combinations_used #=> ["1.0+2.0+3.0+4.0=10.0", "1.0+2.0+3.0=6.0", "1.0+2.0+4.0=7.0", "1.0+2.0=3.0", "1.0+3.0+4.0=8.0", "1.0+3.0=4.0", "1.0+4.0=5.0", "2.0+3.0+4.0=9.0", "2.0+3.0=5.0", "2.0+4.0=6.0", "3.0+4.0=7.0"]
|
54
|
+
```
|
25
55
|
|
26
56
|
## Development
|
27
57
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sum_all_number_combinations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Trott
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|