One line(囧rz) to test isbn13 in ruby
a="9780007103072"
(10-(a.split '').map{|i| i.to_i}[0,12].map.with_index{|n,i| n*(i%2*2+1)}.reduce(:+)%10)%10 == a[12].to_i
Written by Tiao Lims
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#