solver_24 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -5
- data/lib/solver_24/version.rb +1 -1
- data/lib/solver_24.rb +1 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 718be75fa6a180ebf52c990da5c9697e2447dd98
|
4
|
+
data.tar.gz: 8de9f8c47ffe4bd2bcd4d13bdaaa4663d3b21228
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 344f3fdebeafdfbb2f700e0b98fab08e6a07f7502c779c8438fc1dd8b8e4880c9ff6e884a94c7f4bb1102488ec4fa3f380e4949ac2ba914cd4d753b6813d718a
|
7
|
+
data.tar.gz: 011619cf7830d55cf620e3236fe89fbd8f5f8a8b4376893fcc890dd9d9f54c09609fc5411dd696365028d514ac5ca078ebd204c53aec30bda09469970d4e528a
|
data/README.md
CHANGED
@@ -19,14 +19,10 @@ Or install it yourself as:
|
|
19
19
|
|
20
20
|
## Usage
|
21
21
|
|
22
|
-
|
22
|
+
This returns an array of solutions eg: ["( 1.0 + 2.0 + 3.0 ) * 4.0", "( 1.0 * 2.0 ) * 3.0 * 4.0"...]
|
23
23
|
|
24
24
|
`Solver_24.new.solve([1,2,3,4])`
|
25
25
|
|
26
|
-
To return an array of solutions eg: ["( 1.0 + 2.0 + 3.0 ) * 4.0", "( 1.0 * 2.0 ) * 3.0 * 4.0"...]
|
27
|
-
|
28
|
-
`Solver_24.new.show_all_solutions`
|
29
|
-
|
30
26
|
## Development
|
31
27
|
|
32
28
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/solver_24/version.rb
CHANGED
data/lib/solver_24.rb
CHANGED
@@ -12,18 +12,10 @@ class Solver_24
|
|
12
12
|
|
13
13
|
def solve(a)
|
14
14
|
make_possible_solutions(get_sets_of_numbers(a))
|
15
|
-
|
16
15
|
find_solutions
|
17
|
-
|
18
|
-
puts "#{solutions.first} = 24"
|
16
|
+
solutions
|
19
17
|
end
|
20
18
|
|
21
|
-
def show_all_solutions(a)
|
22
|
-
make_possible_solutions(get_sets_of_numbers(a))
|
23
|
-
find_solutions
|
24
|
-
p solutions
|
25
|
-
end
|
26
|
-
|
27
19
|
def get_sets_of_numbers(a)
|
28
20
|
a.permutation(4).to_a.tap do |numbers|
|
29
21
|
numbers.each { |set| set.map!(&:to_f)}
|