Thread: November 2019
View Single Post
Old 2019-11-17, 12:51   #52
LaurV
Romulan Interpreter
 
LaurV's Avatar
 
Jun 2011
Thailand

22·7·317 Posts
Default

You guys are quite good. I actually have no idea how to solve this, beside of "random" or "brute force". The "random" brings you quite fast close to 900M (in just few hours, or less then an hour, depending on your luck), but to advance more, you really need a "clever" way to "improve" the arrangement. By random I mean what I described in my first post, change two elements, and keep the matrix with the highest det, like in the code below (which can be launched with parameters 0 to 3, we played together for half a day, but gave up after being stuck for some long time without any progress. My "best score" is just barely under 900M. I will post the code, some of you may have enough patience, or a lot of more luck... (this is not easy, it is hard, you really need a lot of patience or a lot of luck, that is why I do not consider it spoiler, the code is just some shitty stuff that anybody could put together).

Code:
\\value to beat (loophole) = 923062279
ponder1911(initial=0)=
{
  my(m,x,l,c,d);
  if(initial==0,        \\start from det=0, fast growing for small values till about 500M
        m=[1, 2, 3, 4, 5, 6, 7, 8, 9;
           1, 2, 3, 4, 5, 6, 7, 8, 9;
           1, 2, 3, 4, 5, 6, 7, 8, 9;
           1, 2, 3, 4, 5, 6, 7, 8, 9;
           1, 2, 3, 4, 5, 6, 7, 8, 9;
           1, 2, 3, 4, 5, 6, 7, 8, 9;
           1, 2, 3, 4, 5, 6, 7, 8, 9;
           1, 2, 3, 4, 5, 6, 7, 8, 9;
           1, 2, 3, 4, 5, 6, 7, 8, 9],
  /*else*/
    if(initial==1,      \\det=215233605, but moving fast to over 700M
        m=[1, 2, 3, 4, 5, 6, 7, 8, 9;
           9, 1, 2, 3, 4, 5, 6, 7, 8;
           8, 9, 1, 2, 3, 4, 5, 6, 7;
           7, 8, 9, 1, 2, 3, 4, 5, 6;
           6, 7, 8, 9, 1, 2, 3, 4, 5;
           5, 6, 7, 8, 9, 1, 2, 3, 4;
           4, 5, 6, 7, 8, 9, 1, 2, 3;
           3, 4, 5, 6, 7, 8, 9, 1, 2;
           2, 3, 4, 5, 6, 7, 8, 9, 1],
    /*else*/
      if(initial==2,    \\det=215233605, difficult to move
        m=[1, 2, 3, 4, 5, 6, 7, 8, 9;
           2, 3, 4, 5, 6, 7, 8, 9, 1;
           3, 4, 5, 6, 7, 8, 9, 1, 2;
           4, 5, 6, 7, 8, 9, 1, 2, 3;
           5, 6, 7, 8, 9, 1, 2, 3, 4;
           6, 7, 8, 9, 1, 2, 3, 4, 5;
           7, 8, 9, 1, 2, 3, 4, 5, 6;
           8, 9, 1, 2, 3, 4, 5, 6, 7;
           9, 1, 2, 3, 4, 5, 6, 7, 8],
      /*else*/          \\det=929587995 this is the record for Latin squares, to beat to get two stars
        m=[1, 2, 4, 8, 6, 7, 5, 3, 9;
           9, 1, 2, 4, 8, 6, 7, 5, 3;
           3, 9, 1, 2, 4, 8, 6, 7, 5;
           5, 3, 9, 1, 2, 4, 8, 6, 7;
           7, 5, 3, 9, 1, 2, 4, 8, 6;
           6, 7, 5, 3, 9, 1, 2, 4, 8;
           8, 6, 7, 5, 3, 9, 1, 2, 4;
           4, 8, 6, 7, 5, 3, 9, 1, 2;
           2, 4, 8, 6, 7, 5, 3, 9, 1]
      )
    )
  );
  x=matdet(m);
  print(x";\n "m[1,]"\n "m[2,]"\n "m[3,]"\n "m[4,]"\n "m[5,]"\n "m[6,]"\n "m[7,]"\n "m[8,]"\n "m[9,]);
  while(1,
    l=random(9)+1;
    c=random(9)+1;
    d=m[l,c];
    m[l,c]=m[c,l];
    m[c,l]=d;
    d=matdet(m);
    if(d>x,
      x=d;
      print(x";\n "m[1,]"\n "m[2,]"\n "m[3,]"\n "m[4,]"\n "m[5,]"\n "m[6,]"\n "m[7,]"\n "m[8,]"\n "m[9,]),
    )
  );
}
LaurV is offline   Reply With Quote