The Museum of HP Calculators

HP Forum Archive 19

[ Return to Index | Top of Index ]

Chewing gum for the 50g
Message #1 Posted by Glenn Shields on 18 July 2010, 1:26 p.m.

The use of 'POS' in the last challenge gave me an idea, just type in these two programs: << 1 10 FOR i RAND 4 RND i E-6 * + NEXT 10 ->LIST SORT << E4 * FP 100 * R->I >> MAP >> and store in 'ARRY' then << 1 10 FOR j DUP j POS SWAP NEXT DROP 10 ->LIST R->I >> and store in 'SHUFF'. Then create a list with 'ARRY' to give a permutation of the first 10 (or however many you want) numbers. Then repeated use of 'SHUFF' returns a list of where the numbers were positioned in the first list, but then it toggles back to the original list, on and on, and it seems to work no matter how long the list. Can anyone offer the theory behind this? Thanks in advance. Glenn

      
Re: Chewing gum for the 50g
Message #2 Posted by Han on 20 July 2010, 12:17 a.m.,
in response to message #1 by Glenn Shields

'SHUFF' as programmed a bijective map that is its own inverse.

            
Re: Chewing gum for the 50g
Message #3 Posted by Glenn Shields on 20 July 2010, 9:33 a.m.,
in response to message #2 by Han

Thanks for your swift and sure response. I didn't know what I had stepped into, but it's amazing what a great resource these forum members can be (plus Wikipedia) - who needs school! I also noted which lists are invariant, like numbers in their "proper" positions or pairs in "each other's" position, such as {6,7,4,3,5,1,2,8,10,9}. Cheers, Glenn


[ Return to Index | Top of Index ]

Go back to the main exhibit hall