Find the perl golf solution subroutine that returns the reduced fraction; that is, a fraction that is still equivalent to the initial fraction but using the smaller possible (non-negative!) integer values to make it up. The fraction is returned as an array in the order of (numerator, denominator).
Examples can include:Thanks to tilly for the update.@a = reduce( 512, 1024 ); # @a = ( 1, 2 ) @a = reduce( 12, 18 ); # @a = ( 2, 3 ) @a = reduce( 1, 7 ); # @a = ( 1, 7 )
-----------------------------------------------------
Dr. Michael K. Neylon - mneylon-pm@masemware.com
||
"You've left the lens cap of your mind on again, Pinky" - The Brain
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (Golf) Fraction Reduction
by no_slogan (Deacon) on Jul 25, 2001 at 05:36 UTC | |
|
(MeowChow) Re: (Golf) Fraction Reduction
by MeowChow (Vicar) on Jul 25, 2001 at 07:19 UTC | |
|
Re: (Golf) Fraction Reduction (Russ=45) :-(
by Russ (Deacon) on Jul 26, 2001 at 02:58 UTC |