in reply to Golf Challenge - does $x and $y fit into the same slot on @z?
I hate to spoil the party here but all of the solutions thus far fail on one or more boundary condition.
I suggest adding two test cases:
and$x = 1; $y = 2; @z = (0, 1);
$x = 0; $y = -1; @z = (0, 1);
It is possible that the specification was poorly written but, as it is stated, there is no mention of cases where $x and/or $y are equal to a number in the array. It stands to reason that the safe assumption is that such condition should be considered a failure condition. At the very least, it should be handled consistently. All of the current solutions handle it differently depending on which end of the array the equality occurs at.
Take, for example, the first test I proposed above: $x = 1; $y = 2; @z = (0, 1);. In that case, it obviously not true that $x and $y are between the same numbers in @z. It is also not true that they are both less than all the numbers in @z. Finally, since $x is equal to the last element in @z, it is not true that they are both greater than all elements in @z.
-sauoq "My two cents aren't worth a dime.";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Golf Challenge - does $x and $y fit into the same slot on @z?
by Aristotle (Chancellor) on Dec 28, 2002 at 01:43 UTC | |
|
Re: Re: Golf Challenge - does $x and $y fit into the same slot on @z?
by BrowserUk (Patriarch) on Dec 28, 2002 at 01:54 UTC | |
by sauoq (Abbot) on Dec 28, 2002 at 02:03 UTC | |
by BrowserUk (Patriarch) on Dec 28, 2002 at 02:21 UTC | |
by ehdonhon (Curate) on Dec 28, 2002 at 16:35 UTC | |
by ehdonhon (Curate) on Dec 28, 2002 at 16:28 UTC |