(50G) Inverse Permutation
|
05-28-2015, 09:15 AM
(This post was last modified: 06-15-2017 01:40 PM by Gene.)
Post: #1
|
|||
|
|||
(50G) Inverse Permutation
Given a list of positive integers 1 to g the programme returns the inverse permutation.
eg For input { 1 66 76 94 105 82 62 26 4 50 90 55 99 7 34 104 16 93 39 6 75 28 29 95 64 51 49 24 86 5 9 59 42 97 89 96 23 20 36 22 61 67 35 63 92 80 37 88 30 54 33 38 47 106 41 31 13 2 25 45 81 103 57 17 52 8 100 73 3 91 14 68 101 32 79 78 12 43 56 58 83 21 102 98 48 65 10 18 11 84 87 71 85 46 40 72 44 15 27 70 19 77 53 74 69 60 } the programme returns { 1 58 69 9 30 20 14 66 31 87 89 77 57 71 98 17 64 88 101 38 82 40 37 28 59 8 99 22 23 49 56 74 51 15 43 39 47 52 19 95 55 33 78 97 60 94 53 85 27 10 26 65 103 50 12 79 63 80 32 106 41 7 44 25 86 2 42 72 105 100 92 96 68 104 21 3 102 76 75 46 61 6 81 90 93 29 91 48 35 11 70 45 18 4 24 36 34 84 13 67 73 83 62 16 5 54 } Code: :: |
|||
05-28-2015, 11:17 AM
Post: #2
|
|||
|
|||
RE: HP 50G: Inverse Permutation
I'm not fluent in SysRPL so here is my version of Inverse Permutation for the HP Prime:
Code: EXPORT InvPerm(list) |
|||
05-28-2015, 11:44 AM
Post: #3
|
|||
|
|||
RE: HP 50G: Inverse Permutation
Your prog, Didier, works nicely for well-formed lists but returns an erroneous inverse for eg {1,3,6,4,5}.
It would be better if the prog returned an error. |
|||
05-28-2015, 01:00 PM
Post: #4
|
|||
|
|||
RE: HP 50G: Inverse Permutation | |||
05-28-2015, 02:08 PM
Post: #5
|
|||
|
|||
RE: HP 50G: Inverse Permutation
For input {1 3 6 4 5} my prog returns "Bad Argument Type".
|
|||
05-28-2015, 03:12 PM
(This post was last modified: 05-28-2015 03:52 PM by Didier Lachieze.)
Post: #6
|
|||
|
|||
RE: HP 50G: Inverse Permutation
Does it return the same error message for {1 3 3 4 5}?
Here is the updated version with error handling: Code: EXPORT InvPerm(list) |
|||
05-28-2015, 06:17 PM
Post: #7
|
|||
|
|||
RE: HP 50G: Inverse Permutation
Yes, same error message for two 3s in list.
|
|||
05-29-2015, 05:23 AM
Post: #8
|
|||
|
|||
RE: HP 50G: Inverse Permutation
My prog also returns the same error message for {3,4,5,3,2,1,6}.
|
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)