Rubeuler 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +3 -0
- data/README.md +3 -0
- data/lib/rubeuler/problem.rb +5 -11
- data/lib/rubeuler/solution.rb +15 -0
- data/lib/rubeuler/version.rb +1 -1
- data/lib/rubeuler.rb +4 -2
- metadata +3 -1
data/CHANGELOG.md
ADDED
@@ -0,0 +1,3 @@
|
|
1
|
+
0.0.1 - Initial release, allows you to initialize an instance of Rubeuler::Problem with required options `:number` (int) and `:answer` (string of ruby code). Answer is evaluated and compared to answer predefined in Rubeuler::Problem#solutions method. Result is returned indicating success/failure and the time elapsed when running the code in `:answer`
|
2
|
+
0.0.2 - Fixed Rakefile (gave myself the ability to use `rake release`); Updated description in gemspec
|
3
|
+
0.0.3 - Moved Rubeuler::Problem#solutions to Rubeuler::Solution#for_problem to make the intended use more intuitive
|
data/README.md
CHANGED
@@ -17,6 +17,9 @@ If the answer to problem one is 42, the code below should produce a successful r
|
|
17
17
|
```ruby
|
18
18
|
Rubeuler::Problem.new(number: 1, answer: "7*3*2").execute!
|
19
19
|
```
|
20
|
+
|
21
|
+
__NOTE__: Solutions (see Rubeuler::Solution) are not provided for you. Successfully solve some ProjectEuler problems to build your own list, then use Rubeuler to judge the quality of your solutions.
|
22
|
+
|
20
23
|
### Pull requests/issues
|
21
24
|
|
22
25
|
Please submit any useful pull requests through GitHub. I expect bugs, please report them with the issue tracker! Thanks.
|
data/lib/rubeuler/problem.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'benchmark'
|
2
2
|
|
3
3
|
module Rubeuler
|
4
|
+
include Solution
|
5
|
+
|
4
6
|
class Problem < ::Rubeuler::Base
|
5
7
|
def initialize(options)
|
6
8
|
load_options(:number, :answer, options)
|
@@ -8,7 +10,7 @@ module Rubeuler
|
|
8
10
|
|
9
11
|
def execute!
|
10
12
|
time = Benchmark.measure { @data = answer }.real
|
11
|
-
true_or_false = @data ==
|
13
|
+
true_or_false = @data == solution ? true : false
|
12
14
|
|
13
15
|
return Rubeuler::Result.new(success: true_or_false, problem: @number, data: @data, runtime: time)
|
14
16
|
end
|
@@ -18,16 +20,8 @@ module Rubeuler
|
|
18
20
|
instance_eval(@answer.gsub("\n",";"))
|
19
21
|
end
|
20
22
|
|
21
|
-
def
|
22
|
-
|
23
|
-
"1" => 0,
|
24
|
-
"2" => 0,
|
25
|
-
"3" => 0,
|
26
|
-
"4" => 0,
|
27
|
-
"5" => 0,
|
28
|
-
"6" => 0,
|
29
|
-
"7" => 0
|
30
|
-
}
|
23
|
+
def solution
|
24
|
+
Rubeuler::Solution.for_problem(@number)
|
31
25
|
end
|
32
26
|
end
|
33
27
|
end
|
data/lib/rubeuler/version.rb
CHANGED
data/lib/rubeuler.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Rubeuler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -98,6 +98,7 @@ executables: []
|
|
98
98
|
extensions: []
|
99
99
|
extra_rdoc_files: []
|
100
100
|
files:
|
101
|
+
- CHANGELOG.md
|
101
102
|
- Gemfile
|
102
103
|
- README.md
|
103
104
|
- Rakefile
|
@@ -105,6 +106,7 @@ files:
|
|
105
106
|
- lib/rubeuler/base.rb
|
106
107
|
- lib/rubeuler/problem.rb
|
107
108
|
- lib/rubeuler/result.rb
|
109
|
+
- lib/rubeuler/solution.rb
|
108
110
|
- lib/rubeuler/version.rb
|
109
111
|
- rubeuler.gemspec
|
110
112
|
homepage: http://github.com/rthbound/rubeuler
|