aspose file tools*
The moose likes Programming Diversions and the fly likes Fractions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Other » Programming Diversions
Bookmark "Fractions" Watch "Fractions" New topic
Author

Fractions

Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8883
    
    5
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 ]

Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Joel McNary
Bartender

Joined: Aug 20, 2001
Posts: 1824

5/34 + 7/68 + 9/12 = 1


Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Greg Harris
Ranch Hand

Joined: Apr 12, 2001
Posts: 1012
> 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!


what?
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Damn Joel, you beat me again. Stupid assed sattelite connection went down.
Here's my code:


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Joel McNary
Bartender

Joined: Aug 20, 2001
Posts: 1824

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
Sheriff

Joined: Oct 14, 2002
Posts: 8883
    
    5
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.
 
 
subject: Fractions