Small Change by flagitious

#!ruby -pla
z,*o=$F.map &:to_i
*b=[]
*f=0
f.map{|t|t<z&&o.map{|c|b[c+t]||=f<<c+t&&b[t]+[c]}}
$_=[b[z]||:-]*' '

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return top