>> Jason Purdy <[EMAIL PROTECTED]> writes: > Is that #*1.11%10 a number theory to get to the same number? How did > someone recognize that pattern? (my advanced calculus/comb math being > a lil' rusty)
I don't know others, but I started by looking at the input and output, like this: 0 0 1 1 ... ... 9 9 10 1 11 2 12 3 ... ... 18 9 19 1 20 2 As you can see it's just a series of 1 .. 9, except for 0. With that in mind my first I tried something like (0,(1..9)x11)[$n]. Actually, before that I tried something more like (0,(1..9)x2)[$a+$b] (where $a and $b are the digits). Then I noticed that I could get the same result using %9 and some conditionals. After putting this stuff aside and having some sleep I just pictured the thing as a table like this: 0 1 2 3 4 ... 0 00 11 22 33 44 ... 1 10 21 32 43 54 ... ... 8 80 91 12 23 34 ... 9 90 11 22 33 44 ... which made it kind of evident that 111%100 should do what I wanted. *Then* I had a different problem to solve :-) > What is \G ... $&? Gotta dig out my Camel book again. Check out perlre and perlvar and the "g" option to m//. A question of my own: why doesn't s/\B.\B/$&$&/g work as I expect, namely abcd -> abbccd. I really can't figure it out by reading the docs. TIA, Marcelo