Very Silly One Liner....

J

John Carter

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




John Carter Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : (e-mail address removed)
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.
 
M

Martin DeMello

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top