2018-02-21 23:07:31 +00:00
|
|
|
# miscellaneous stuff
|
|
|
|
|
2018-02-23 04:53:01 +00:00
|
|
|
require "big"
|
|
|
|
|
2018-02-21 23:07:31 +00:00
|
|
|
module Euler
|
2018-02-25 03:32:39 +00:00
|
|
|
extend self
|
|
|
|
|
|
|
|
alias NumType = Int32 | Int64 | UInt32 | UInt64
|
|
|
|
|
2018-02-25 03:43:30 +00:00
|
|
|
def to_big_ints(num_list : Array(NumType))
|
|
|
|
num_list.map { |n| BigInt.new(n) }
|
2018-02-23 04:53:01 +00:00
|
|
|
end
|
|
|
|
|
2018-02-25 03:43:30 +00:00
|
|
|
def to_digit_list(n : NumType | BigInt)
|
|
|
|
n.to_s.chars.map { |d| d.to_i }
|
|
|
|
end
|
2018-02-25 03:32:39 +00:00
|
|
|
|
|
|
|
def palindrome?(x)
|
|
|
|
x.to_s.reverse == x.to_s
|
2018-02-23 04:53:01 +00:00
|
|
|
end
|
2018-02-21 23:07:31 +00:00
|
|
|
end
|