Last Updated: February 25, 2016
·
325
· douo

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