UPC: Difference between revisions

41 bytes removed ,  4 years ago
m
(julia example)
Line 266:
mats, dig, dsum = filter(!isempty, m.captures), Int[], 0
for mat in mats
append!(dig, [ptod1[x.match] for x in eachmatch(r"(.......)", mat)
if haskey(ptod1, x.match)])
append!(dig, [ptod2[x.match] for x in eachmatch(r"(.......)", mat)
if haskey(ptod2, x.match)])
end
dsum += sum([(isodd(i) ? 3 : 1) * n for (i, n) in enumerate(dig)])
if (dsum % 10 == 0) && return prod(string.(dig))
return prod(string.(dig))
end
end
 
return ""
end
Line 310 ⟶ 308:
653483540435
</pre>
 
 
=={{header|Perl}}==
4,105

edits