#!/usr/bin/env ruby
# Solution for:
# This problem can be solved by pre-school children in 5-10 minutes,
# by programmers - in 1 hour, by people with higher education...
# well, check it yourself :)
def enigma array
array.each do |x|
print "#{enigma2(x)} "
end
puts
end
def enigma2 x
i=0
x.each_char do |y|
case Integer(y)
when 0,6,9
i+=1
when 8
i+=2
end
end
i
end
zero=['7111','2172','1111','3213','2222','3333','5555','7777','5531']
one=['9313','7756']
two=['7662']
three=['8193','6855']
four=['6666','0000','9999']
five=['8096','9881']
six=['8809']
unknown=['2581']
enigmas=[zero,one,two,three,four,five,six,unknown]
enigmas.each do |x|
enigma x
end