Sha256: 6bb3aa415535997fee0241c38bb0b31b9a2028f0c8a812fcccb4289cb445b411
Contents?: true
Size: 994 Bytes
Versions: 188
Compression:
Stored size: 994 Bytes
Contents
require 'minitest/autorun' require_relative 'pythagorean_triplet' class TripletTest < Minitest::Test def test_sum assert_equal 12, Triplet.new(3, 4, 5).sum end def test_product skip assert_equal 60, Triplet.new(3, 4, 5).product end def test_pythagorean skip assert Triplet.new(3, 4, 5).pythagorean? end def test_not_pythagorean skip refute Triplet.new(5, 6, 7).pythagorean? end def test_triplets_upto_10 skip triplets = Triplet.where(max_factor: 10) products = triplets.map(&:product).sort assert_equal [60, 480], products end def test_triplets_from_11_upto_20 skip triplets = Triplet.where(min_factor: 11, max_factor: 20) products = triplets.map(&:product).sort assert_equal [3840], products end def test_triplets_where_sum_x skip triplets = Triplet.where(sum: 180, max_factor: 100) products = triplets.map(&:product).sort assert_equal [118_080, 168_480, 202_500], products end end
Version data entries
188 entries across 188 versions & 1 rubygems