From: Martin DeMello Date: 2006-08-22T18:33:46+09:00 Subject: Re: Very Silly One Liner.... On 8/22/06, John Carter wrote: > Here is my very very silly one liner for the day.... > > ruby -e '100.times{|n| a,b=n.divmod 10;10.times{|c|;d=c*10+a;next unless > d!=0&&n%d==0&&b==c*n/d;printf "%02d/%02d=%d\n",n,d,n/d}}' > 00/10=0 > 00/20=0 > 00/30=0 > 00/40=0 > 00/50=0 > 00/60=0 > 00/70=0 > 00/80=0 > 00/90=0 > 10/01=10 > 11/11=1 > 20/02=10 > 22/22=1 > 30/03=10 > 33/33=1 > 40/04=10 > 44/44=1 > 50/05=10 > 55/55=1 > 60/06=10 > 64/16=4 > 66/66=1 > 70/07=10 > 77/77=1 > 80/08=10 > 88/88=1 > 90/09=10 > 95/19=5 > 98/49=2 > 99/99=1 Took me a good minute to figure out what you were doing there :) Cute, though I submit that n/d = 10 and n/d = 1 are artistically unsatisfying, particularly the former. Plus you miss a nice case... ruby -rrational -e '100.times{|n| a,b=n.divmod 10;10.times{|c|d=c*10+a;next unless (n!=d) && (b*d!=0) && (b*d==c*n);printf "%02d/%02d=#{Rational(n,d)}\n",n,d}}' 64/16=4 65/26=5/2 95/19=5 98/49=2 martin