#!ruby -pl n,s=0 s="%X#{gsub(/\S\b/){n+=$&.hex p} t=s}".%n%10+1until~0>n=n/10-1 $_=t