hotshot has asked for the wisdom of the Perl Monks concerning the following question:
In general, I can join all the arrays to a big one, sort it, and check that each array value equals the array's index, but I'll fall in case the user enters:Example 1: (iteration 1): 0 1 2 (iteration 2): 4 6 5 ### Wrong input - missing 3, and second array is not consecutive Example 2: (iteration 1): 4 5 6 (iteration 2): 0 1 2 3 4 ### Wrong - 4 appears twice Example 3: (iteration 1): 4 5 6 7 8 (iteration 2): 0 1 2 3 ### this one is OK
The joined array will qualify but the little ones not. anyone has a short idea (long solutions I have in plenty, but probably very ugly) ?first: 0 1 3 second: 2 4 5
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: joining and sorting arrays
by strat (Canon) on Dec 04, 2001 at 22:18 UTC | |
by strat (Canon) on Dec 05, 2001 at 15:59 UTC | |
|
Re: joining and sorting arrays
by ehdonhon (Curate) on Dec 04, 2001 at 22:19 UTC | |
by tye (Sage) on Dec 04, 2001 at 23:41 UTC | |
|
(jeffa) Re: joining and sorting arrays
by jeffa (Bishop) on Dec 04, 2001 at 22:30 UTC | |
by hotshot (Prior) on Dec 04, 2001 at 22:37 UTC | |
by fuzzysteve (Beadle) on Dec 04, 2001 at 23:47 UTC | |
|
Re: joining and sorting arrays
by Zaxo (Archbishop) on Dec 04, 2001 at 23:20 UTC | |
|
Re: joining and sorting arrays
by Masem (Monsignor) on Dec 04, 2001 at 22:58 UTC | |
|
Re: joining and sorting arrays
by George_Sherston (Vicar) on Dec 04, 2001 at 22:47 UTC |