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 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.
@@ -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 == solutions[@number.to_s] ? true : false
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 solutions
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
@@ -0,0 +1,15 @@
1
+ module Rubeuler
2
+ module Solution
3
+ def self.for_problem number
4
+ {
5
+ "1" => 0,
6
+ "2" => 0,
7
+ "3" => 0,
8
+ "4" => 0,
9
+ "5" => 0,
10
+ "6" => 0,
11
+ "7" => 0
12
+ }[number.to_s]
13
+ end
14
+ end
15
+ end
@@ -1,3 +1,3 @@
1
1
  module Rubeuler
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/rubeuler.rb CHANGED
@@ -1,4 +1,6 @@
1
+ require "rubeuler/version"
2
+ require "rubeuler/result"
1
3
  require "rubeuler/base"
4
+ require "rubeuler/solution"
2
5
  require "rubeuler/problem"
3
- require "rubeuler/result"
4
- require "rubeuler/version"
6
+
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.2
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