Is it possible to sort 4 integers in either descending/ascending order using ONLY Math.min and Math.max?
Cannot use the "if", "while", "for", "switch" keywords.
On Wed, 02 Feb 2005 18:49:27 +0800, Bern wrote:[color=blue]
> Is it possible to sort 4 integers in either descending/ascending
> order using ONLY Math.min and Math.max? Cannot use the "if",
> "while", "for", "switch" keywords.[/color]
Yes, each of the four ranks can be represented by an expression that
uses only nested combinations of min() and max().
I won't post any code since the keyword restriction makes it sound
like a homework question.
/gordon
--
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
Comment