Snippet

project_euler/36.rb
Code:
# Project Euler Problem 36: Double-base Palindromes

# https://projecteuler.net/problem=36

def double_base_palindrome?(n, a = 2, b = 10)
    (n.to_s(a) == n.to_s(a).reverse) && (n.to_s(b) == n.to_s(b).reverse)
end

def solve(n)
    (1..n).to_a.filter { |m| double_base_palindrome?(m) }.sum
end

puts solve(1_000_000)
Output:
872187