sorting of numbers

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bern

    #1

    sorting of numbers

    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.
  • Gordon Beaton

    #2
    Re: sorting of numbers

    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

    Working...