Chewing gum for the 50g - Printable Version +- HP Forums (https://archived.hpcalc.org/museumforum) +-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html) +--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html) +--- Thread: Chewing gum for the 50g (/thread-169705.html) Chewing gum for the 50g - Glenn Shields - 07-18-2010 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 - Han - 07-20-2010 'SHUFF' as programmed a bijective map that is its own inverse. Re: Chewing gum for the 50g - Glenn Shields - 07-20-2010 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