Sha256: 06f6871b1b9e1190c9b3f689552ea0d4f5ea681e35fe7c0d9f9c9f6e97415499
Contents?: true
Size: 1.51 KB
Versions: 45
Compression:
Stored size: 1.51 KB
Contents
#!/usr/bin/env ruby require 'minitest/autorun' require_relative 'palindrome_products' class PalindromesTest < Minitest::Test def test_largest_palindrome_from_single_digit_factors palindromes = Palindromes.new(max_factor: 9) palindromes.generate largest = palindromes.largest assert_equal 9, largest.value assert_includes [[[3, 3], [1, 9]], [[1, 9], [3, 3]]], largest.factors end def test_largest_palindrome_from_double_digit_factors skip palindromes = Palindromes.new(max_factor: 99, min_factor: 10) palindromes.generate largest = palindromes.largest assert_equal 9009, largest.value assert_equal [[91, 99]], largest.factors end def test_smallest_palindrome_from_double_digit_factors skip palindromes = Palindromes.new(max_factor: 99, min_factor: 10) palindromes.generate smallest = palindromes.smallest assert_equal 121, smallest.value assert_equal [[11, 11]], smallest.factors end def test_largest_palindrome_from_triple_digit_factors skip palindromes = Palindromes.new(max_factor: 999, min_factor: 100) palindromes.generate largest = palindromes.largest assert_equal 906_609, largest.value assert_equal [[913, 993]], largest.factors end def test_smallest_palindrome_from_triple_digit_factors skip palindromes = Palindromes.new(max_factor: 999, min_factor: 100) palindromes.generate smallest = palindromes.smallest assert_equal 10_201, smallest.value assert_equal [[101, 101]], smallest.factors end end
Version data entries
45 entries across 45 versions & 1 rubygems