Very Silly One Liner

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=c10+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

John C. Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : [email protected]
New Zealand

Carter’s Clarification of Murphy’s Law.

“Things only ever go right so that they may go more spectacularly wrong
later.”

From this principle, all of life and physics may be deduced.

On 8/22/06, John C. [email protected] 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=c10+a;next unless
d!=0&&n%d==0&&b==c
n/d;printf “%02d/%02d=%d\n”,n,d,n/d}}’

11/11=1
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 :slight_smile: 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=c10+a;next unless (n!=d) && (bd!=0) &&
(bd==cn);printf “%02d/%02d=#{Rational(n,d)}\n”,n,d}}’

64/16=4
65/26=5/2
95/19=5
98/49=2

martin