(50G) Inverse Permutation
05-28-2015, 09:15 AM (This post was last modified: 06-15-2017 01:40 PM by Gene.)
Post: #1
 Gerald H Senior Member Posts: 1,452 Joined: May 2014
(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:
::   CK1   FPTR 7 17B   DUP   toLEN_DO   DUPINDEX@   NTHCOMPDROP   INDEX@   FPTR2 ^#>Z   SWAP   FPTR2 ^Z2BIN   4ROLL   PUTLIST   SWAPLOOP   DROP ;
 « Next Oldest | Next Newest »

 Messages In This Thread (50G) Inverse Permutation - Gerald H - 05-28-2015 09:15 AM RE: HP 50G: Inverse Permutation - Didier Lachieze - 05-28-2015, 11:17 AM RE: HP 50G: Inverse Permutation - Gerald H - 05-28-2015, 11:44 AM RE: HP 50G: Inverse Permutation - Didier Lachieze - 05-28-2015, 01:00 PM RE: HP 50G: Inverse Permutation - Gerald H - 05-28-2015, 02:08 PM RE: HP 50G: Inverse Permutation - Didier Lachieze - 05-28-2015, 03:12 PM RE: HP 50G: Inverse Permutation - Gerald H - 05-28-2015, 06:17 PM RE: HP 50G: Inverse Permutation - Gerald H - 05-29-2015, 05:23 AM

User(s) browsing this thread: 1 Guest(s)