6 Replies Latest reply on Mar 23, 2012 5:38 AM by PeterWindle

# Is this not "GENIUS" ? I am amazed

Hello Experts. I am just starting to disect this code from Agnés Barouh over @ tictac.fr and i tell you. This stuff is blowing my mind:

Here is her calculation to create a list in the beginning.

Let ( [

NumCalc = Substitute ( ( 10 ^ 33) -1 ; 9 ; "100100100" );

List1_99 = Substitute ( "_00" & NumToJText( Left ( NumCalc * NumCalc; 295) ; 1 ; 0 ) ;

["," ; "_"] ; ["." ; "_"] );

\$List100_199 = "_100" & Substitute ( List1_99 ; ["_0"; "_1"] );

EndMax = LeftWords ( List1_99 & \$List100_199 & "_200"; Int( ( /*End variable-->*/300 -100 ) /100 ) + 1 );

FinalList = MiddleWords ( List1_99 & Evaluate ( Substitute ( "("_" & EndMax ;

[ "_"; ( "|Substitute( \$List100_199; "_1"; "_" ) ];

["|"; "" ) & "] ) & "")" ); /*start variable--> */ 1 ; /* End variable-->*/ 300 - 1 + /*Start Var-->*/ 1 )

];

FinalList

)*

** i have testes this with a few minor adjustments ( * End variable-->*/ 300 & /*start variable--> */ 1) - these are parameters for the custom function

CustomList

What i am amazed at was the use of this: Substitute ( ( 10 ^ 33) -1 ; 9 ; "100100100" ); which came up with this list of numbers,

1001001001001001001001001001001001001001001001001001001001

001001001001001001001001001001001001001001001001001001001001001001

00100100100100100100100100100100100100100100100100100100100100100100100

1001001001001001001001001001001001001001001001001001001001001001001001001

00100100100100100100100100100

Then she breaks it down using the function NumtoJText ( left ( Numcalc * Numcalc; 295 ) ; 1 ;0 //THis i dont understand how you would come up with using 295, i changed this to a few other numbers but it messed up the contiguous list ..

_001_002_003_004_005_006_007_008_009_010_011_012_013_014_015_016_017_018_

019_020_021_022_023_024_025_026_027_028_029_030_031_032_033_034_035_036_

037_038_039_040_041_042_043_044_045_046_047_048_049_050_051_052_053_054_

055_056_057_058_059_060_061_062_063_064_065_066_067_068_069_070_071_072_

073_074_075_076_077_078_079_080_081_082_083_084_085_086_087_088_089_090_

091_092_093_094_095_096_097_098_099

AMAZING RIGHT!!

-i

• ###### 1. Re: Is this not "GENIUS" ? I am amazed

Agreed, Ian, that this is an amazing formula. Just out of curiosity, what does it do or what is the purpose?

• ###### 2. Re: Is this not "GENIUS" ? I am amazed

Yes. Seems to be a clever application of the quadratic binomial law (a + b)^2 = a^2 + 2ab + b^2 for numbers that are composed of the digit 1.

1*1 = 1

11 *11 = 121 = (10 + 1)^2  = 100 + 20 + 1^2 = 100 + 20 + 1

111*111 = 12321 = (100 + 11)^2 = 10000 + 2200 + (10 + 1)^2 = 10000 + 2200 + 100 + 20 + 1

1111*1111 = 1234321

11111*11111 = 123454321

and so on.

I.e. you expand first the left part of the binomial formula yielding a^2 + 2ab , and substitute into b^2 the binomial formula of the previous member.

In addition, Agnés inserts zeros in between, which does not change the general scheme, e.g. instead of 1, 121, 12321, you now have 10000, 10020010000, 10020030020010000 upon insertion of two zeros, so again a counting up and down of the digits.

Using the left truncation, she just cuts off the right part with the digits being counted down.

Edit: I suppose Agnés must have liked maths in school (as I had).

Message was edited by: MartinBraendle

• ###### 3. Re: Is this not "GENIUS" ? I am amazed

Actually, i thought it was based on a mathematical formula, i have a DIRECT response from Agnés herself. Here it is.

First, Substitute() is for me THE function in FileMaker, I find this function very very powerful and very very fast.

and I was convinced that just with Substitute, without recursion, you could get a numbered list.

the beginning, I would like to write a list :

1=1

2=2

3=3

n=n

without recursion

I started to analyze the number and testing, I got to fold 11 x 11

11 x 11 = 121

111 x 111 = 12321...

11111 x 11111 = 123454321

so

11111111 ^ 2 = 123456787654321

it was successful in separating this string for a list, keeping only the first half

and that is comes NumToJText we put a comma every 3 numbers ( saw Function NumbertFormat() we used this "astuce" ) => http://www.briandunning.com/cf/945

101 x 101 = 10201... so 1001 x 1001 = 1002001 and NumToJText ( "1002001" ; 1 ; 0 ) gives 1,002,001 and

Let ([

n = 1001 ^ 2

];

"00" & NumToJText ( Left ( n ; Length ( n ) / 2 + 1  )  ; 1 ; 0 )

)

= 001,002.... the beginning of the first version of CustomList

for this first version, I could not find how to generate the list with Evaluate in Evaluate,

when I found out I have wrote the 2nd version of CustomList ( more records )

left ( Substitute ( ( 10 ^ 33) -1 ; 9 ; "100100100" ) * Substitute ( ( 10 ^ 33) -1 ; 9 ; "100100100" ) ; 295 )

for take only the first par the list who interested me.

295... in memory, remove the last 4 0 of the number and divide its length by 2

let ([

n = Substitute ( ( 10 ^ 1) -1 ; 9 ; "100100100" ) * Substitute ( ( 10 ^ 1) -1 ; 9 ; "100100100" )

];

ceiling ( (  Length  ( n ) - 4 ) / 2  )

)

She basically just kept trying and trying until she figured it out!.. DID I mention Perserverence as well!!

• ###### 4. Re: Is this not "GENIUS" ? I am amazed

yes, it's a fun example

to those attempting to accent Agnès' name correctly — are you using a grave

accent and the site is converting it to an acute accent?

• ###### 5. Re: Is this not "GENIUS" ? I am amazed

<NOPE>

Macbook  with keycombo  »option» e

é

• ###### 6. Re: Is this not "GENIUS" ? I am amazed

4 8 15 16 23 42