• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Fractions

 
author
Posts: 9050
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Given the digits from 1 to 9, and using each digit once, create three fractions of the form:

x
----- ( x is a 1 digit number, y y is a two digit number)
y y
so that:

(break out your for loops )
[ June 05, 2003: Message edited by: Bert Bates ]
 
Bartender
Posts: 1844
Eclipse IDE Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
5/34 + 7/68 + 9/12 = 1
 
Ranch Hand
Posts: 1012
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> 5/34 + 7/68 + 9/12 = 1
joel beat me to the post... this code is very messy - but it works. i hate nested for loops!
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Damn Joel, you beat me again. Stupid assed sattelite connection went down.
Here's my code:
 
Joel McNary
Bartender
Posts: 1844
Eclipse IDE Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For the record, here's my code:
Anagrammer.java

Fractions.java

Not the most elegant solution, (and the print out is sloppy), but it was developed in 3 minutes (I already had the Anagrammer class written....)
I spent half the day trying to do it by hand, just to see it I could. No such luck, so I threw this code together
[ June 06, 2003: Message edited by: Joel McNary ]
 
Bert Bates
author
Posts: 9050
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Joel, Michael, Greg -
WOW !!! You guys did that fast!!! A lot faster than I did it (which may be damned by faint praise ),
I seem to recall some sort of recursive solution...
A friend once described his very elegant high level design for the 'knight's tour' problem, which I'll post next.
 
Bras cause cancer. And tiny ads:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic