Skip to content

Commit

Permalink
solve problem 29
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshCheek committed Jun 27, 2011
1 parent e2c7329 commit da4d7d9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
21 changes: 21 additions & 0 deletions project_euler/lib/project_euler/problems/029.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'project_euler'

module ProjectEuler
class Problem29

def solve_for(n)
solutions = []
(2..n).each do |a|
(2..n).each do |b|
solutions << a**b
end
end
solutions.uniq.size
end

def solution
solve_for 100
end

end
end
7 changes: 7 additions & 0 deletions project_euler/spec/problems/029_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'spec_helper'
require 'project_euler/problems/029'

describe ProjectEuler::Problem29 do
specify { subject.solve_for(5).should == 15 }
its(:solution) { should == 9183 }
end

0 comments on commit da4d7d9

Please sign in to comment.