Check The Validity Of A Euro Banknote Serial Number (one-liner)
Join the DZone community and get the full member experience.
Join For Free
def valid_euro?(sn)
(sn[0] - ?A + 1 + sn.scan(/\d/).map{|c| c.to_i }.inject{|d, s| d + s }) % 9 == 8
end
Opinions expressed by DZone contributors are their own.
Comments