On Wed, Mar 03, 2004 at 11:32:24AM -0600, Riley wrote: > What strikes me as particularly odd is the fact that we all > needed to add a certain amount to the above expression, > namely @F/2 - 27, where the y-intercept is 27 (or 3**3).
Actually no. Those who used @F/2 needed to add 28 (since @F/2 is too big...) > I guess my question is this: Is this just a coincidence, the > fact that our y-intercept is also a power of 3, and not > just any power of the three, but the next in sequence? It's not a coincidence, but I don't think there's any deep meaning there either. It's just the way that the maths work out [obviously everyone did the maths, or I missed some really easy shortcut :-)]. Blatantly reused from my blog [1]: [quote] The way I thought of the formula was this: Given an index I into the set of cards (for example with the 21 cards below, 0-20) and the pick P (1-3) we need a formula for determining from I and P the index which would get translated to I. 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Let's determine this by hand for for the interesting elements (we're only interested in cards that are rearranged into the middle third): 7 8 9 10 11 12 13 1 0 3 6 9 12 15 18 2 1 4 7 10 13 16 19 3 2 5 8 11 14 17 20 Obviously ( "so the professor said 'I thought about this for three days, and you were right; it is obvious'"... ) our formula looks like I' = P + 3I - 22. To generalize this we just note that 22 is the number of cards + 1 (which in turn happens to be @F-2). Now, to solve the problem we just need to remember that the card that we're interested in ends up in the middlemost position (i.e. for 21 cards in index 10, @F/2-2), and we can just repeat the formula three times to find out the original position: I_0 = @F/2-2 I_1 = P_3 + 3*I_0 - (@F-2) = P_3 + 3*(@F/2-2) - @F + 2 = P_3 + @F/2 - 4 I_2 = P_2 + 3*I_1 - (@F-2) = P_2 + 3*(P_3 + @F/2 - 4) - @F + 2 = P_2 + 3*P_3 + @F/2 - 10 I_3 = P_1 + 3*I_2 - (@F-2) = P_1 + 3*P_2 + 9*P_3 + @F/2 - 28 [/quote] The constant I_x is always -(3^i*x + 1), since the operations we do on it (multiply by 3, add 2) always transform it back to the same form (just incrementing "i" by 1). If instead of @F/2 we use something that happens to be smaller (for example s/ ..(.)//g), we can drop the "+1" from that, and just get 3^i. Or were you asking about something else? :-) [1] <http://www.iki.fi/jsnell/blog/>, currently has mainly explanations on some recent minigolf solutions, so I don't feel too bad about mentioning it here... ;-) -- Juho Snellman