F2L

>    ##################################
##################################
F2L1:=proc(A,affichage)
local i,j,j1,j2,m,ok,Liste1,Liste2,a,b0,c1,c2,p,AF2LLL,Aalgo;
Aalgo:=[];ok:=0;
AF2LLL:=A;


for i to 4 do

# préliminaires ooooooooooooooooooooooooooooooooooooo
Liste1:=cas0(AF2LLL)[4];
Liste2:=cas0(AF2LLL)[5];
    if affichage=1 then  
print(`Listeok`,Liste1);print(`ListepasOK`,Liste2); print(AF2LLL[41],AF2LLL[42],AF2LLL[43],AF2LLL[44]);
print(` Algo X : `, nbalgoX(AF2LLL[40+i])); end if;
   
 Liste1:=algoListe(AF2LLL[40+i],Liste1);
  Aalgo:=[op(Aalgo),nbalgoX(AF2LLL[40+i])];AF2LLL:=algo([nbalgoX(AF2LLL[40+i])],AF2LLL);
# fin des préliminaires ooooooooooooooooooooooooooooooooooooooooooo

  
if member(AF2LLL[40+i],Liste1) then
            if affichage=1 then  print(`n°   `,i,` ok`);end if;
else
for j to 6 do
#xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
 
if TestF2L(AF2LLL,2)[j]=1 then m:=cat(cas,j)(AF2LLL,2); AF2LLL:=m[3];
                                            if affichage=1 then  print(`cas n° `,j, `pour paire `,i);print(m[2]);
                                            print(`on a j=  `,j,` donc .... `);end if;
                                           Aalgo:=[op(Aalgo),op(m[2])];
   if j>2 then    
      for j1 to 2 do
      if TestF2L(AF2LLL,2)[j1]=1 then m:=cat(cas,j1)(AF2LLL,2); AF2LLL:=m[3];
                                          if affichage=1 then  print(`cas n° `,j1, `pour paire `,i);print(m[2]); end if;
                                           Aalgo:=[op(Aalgo),op(m[2])];
      end if; end do;
    end if;
    break;
#xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

elif TestF2L(AF2LLL,2)=[0,0,0,0,0,0] then     
a:=[]; b0:=[]; p:=[0,0];
if AF2LLL[25]=2 then a:=[iX];c1:=1;p[1]:=1;
elif AF2LLL[27]=2 then a:=[];c1:=2;p[1]:=1;
elif AF2LLL[29]=2 then a:=[X];c1:=3;p[1]:=1;
elif AF2LLL[31]=2 then a:=[X2];c1:=4;p[1]:=1;
end if;
if AF2LLL[9]=6 then b0:=[iX];c2:=1;p[2]:=1;
elif AF2LLL[11]=6 then b0:=[];p[2]:=1;c2:=2;
elif AF2LLL[13]=6 then b0:=[X];p[2]:=1;c2:=3;
elif AF2LLL[15]=6 then b0:=[X2];p[2]:=1;c2:=4;
end if;

#################
if p=[0,1] then  Liste1:=algoListe(c2,Liste1); AF2LLL:=algo(b0,AF2LLL); Aalgo:=[op(Aalgo),op(b0)];
    for j2 to 6 do
    if TestF2L(AF2LLL,AF2LLL[40+i])[j2]=1 then m:=cat(cas,j2)(AF2LLL,AF2LLL[40+i]); AF2LLL:=m[3];
                                            if affichage=1 then  print(`cas n° `,j2, `pour paire `,i);print(b0);print(m[2]); end if;
                                               Aalgo:=[op(Aalgo),op(m[2])];

if affichage=1 then  print(`     Algo X : `, nbalgoX(AF2LLL[40+i])); end if;
Liste1:=algoListe(AF2LLL[40+i],Liste1);
Aalgo:=[op(Aalgo),nbalgoX(AF2LLL[40+i])];AF2LLL:=algo([nbalgoX(AF2LLL[40+i])],AF2LLL);

       if j2>2 then  
          for j1 to 2 do
          if TestF2L(AF2LLL,AF2LLL[40+i])[j1]=1 then m:=cat(cas,j1)(AF2LLL,AF2LLL[40+i]); AF2LLL:=m[3];
                                            if affichage=1 then  print(`cas n° `,j1, `pour paire `,i);print(m[2]); end if;
                                               Aalgo:=[op(Aalgo),op(m[2])];
          end if; end do;
        end if;break;
    end if;  end do;   break;##
#################
#################
elif p=[1,0] then Liste1:=algoListe(c1,Liste1); AF2LLL:=algo(a,AF2LLL); Aalgo:=[op(Aalgo),op(a)];
    for j2 to 6 do
    if TestF2L(AF2LLL,AF2LLL[40+i])[j2]=1 then m:=cat(cas,j2)(AF2LLL,AF2LLL[40+i]); AF2LLL:=m[3];
                                            if affichage=1 then  print(`cas n° `,j2, `pour paire `,i);print(a);print(m[2]); end if;
                                               Aalgo:=[op(Aalgo),op(m[2])];

if affichage=1 then  print(`   Algo X : `, nbalgoX(AF2LLL[40+i])); end if;
Liste1:=algoListe(AF2LLL[40+i],Liste1);
Aalgo:=[op(Aalgo),nbalgoX(AF2LLL[40+i])];AF2LLL:=algo([nbalgoX(AF2LLL[40+i])],AF2LLL);

       if j2>2 then
          for j1 to 2 do
          if TestF2L(AF2LLL,AF2LLL[40+i])[j1]=1 then m:=cat(cas,j1)(AF2LLL,AF2LLL[40+i]); AF2LLL:=m[3];
                                            if affichage=1 then  print(`cas n° `,j1, `pour paire `,i);print(m[2]); end if;
                                               Aalgo:=[op(Aalgo),op(m[2])];
          end if; end do;
       end if;break;
    end if; end do;   break;##

#################
 
 
#################
elif p=[1,1] then     
#1 Le coin et l'arrête sont collés ailleurs
 if a=b0 then Liste1:=algoListe(c1,Liste1); AF2LLL:=algo(op(a),AF2LLL); Aalgo:=[op(Aalgo),op(a)];
for j2 to 6 do
   if TestF2L(AF2LLL,AF2LLL[40+i])[j2]=1 then m:=cat(cas,j2)(AF2LLL,AF2LLL[40+i]);
                                                      AF2LLL:=m[3];
                                            if affichage=1 then  print(`cas n° `,j2, `pour paire `,i);print(a);print(m[2]); end if;
                                              Aalgo:=[op(Aalgo),op(m[2])];

if affichage=1 then  print(`   Algo X : `, nbalgoX(AF2LLL[40+i])); end if;
Liste1:=algoListe(AF2LLL[40+i],Liste1);
Aalgo:=[op(Aalgo),nbalgoX(AF2LLL[40+i])];AF2LLL:=algo([nbalgoX(AF2LLL[40+i])],AF2LLL);


       if j2>2 then  
         for j1 to 2 do
         if TestF2L(AF2LLL,AF2LLL[40+i])[j1]=1 then m:=cat(cas,j1)(AF2LLL,AF2LLL[40+i]); AF2LLL:=m[3];
                                              if affichage=1 then  print(`cas n° `,j1, `pour paire `,i);print(m[2]); end if;
                                              Aalgo:=[op(Aalgo),op(m[2])];
          
          end if; end do;
       end if;break;
   end if; end do; break;##
 
#2 Le coin et l'arrête sont à l'Ouest
 elif a<>b0 then Liste1:=algoListe(c1,Liste1); AF2LLL:=algo(a,AF2LLL); Aalgo:=[op(Aalgo),op(a)];
                     if affichage=1 then  print(`algo X :   `,a);print(`  iU,R,U   `, `pour paire `,i); end if;

AF2LLL:=algo([iU,R,U],AF2LLL); Aalgo:=[op(Aalgo),iU,R,U];
if AF2LLL[9]=AF2LLL[40+i]+4 then b0:=[iX];c2:=1;
elif AF2LLL[11]=AF2LLL[40+i]+4 then b0:=[];c2:=2;
elif AF2LLL[13]=AF2LLL[40+i]+4 then b0:=[X];c2:=3;
elif AF2LLL[15]=AF2LLL[40+i]+4 then b0:=[X2];c2:=4;
end if;

Liste1:=algoListe(c2,Liste1); AF2LLL:=algo(b0,AF2LLL); Aalgo:=[op(Aalgo),op(b0)];
for j2 to 6 do
   if TestF2L(AF2LLL,AF2LLL[40+i])[j2]=1 then m:=cat(cas,j2)(AF2LLL,AF2LLL[40+i]); AF2LLL:=m[3];
                                            if affichage=1 then  print(`cas n° `,j2, `pour paire `,i);print(b0);print(m[2]); end if;
                                              Aalgo:=[op(Aalgo),op(m[2])];

if affichage=1 then  print(`   Algo X : `, nbalgoX(AF2LLL[40+i])); end if;
Liste1:=algoListe(AF2LLL[40+i],Liste1);
Aalgo:=[op(Aalgo),nbalgoX(AF2LLL[40+i])];AF2LLL:=algo([nbalgoX(AF2LLL[40+i])],AF2LLL);

       if j2>2 then
         for j1 to 2 do
         if TestF2L(AF2LLL,AF2LLL[40+i])[j1]=1 then m:=cat(cas,j1)(AF2LLL,AF2LLL[40+i]); AF2LLL:=m[3];
                                            if affichage=1 then  print(`cas n° `,j1, `pour paire `,i);print(m[2]); end if;
                                              Aalgo:=[op(Aalgo),op(m[2])];
         end if; end do;
       end if;break;
   end if; end do;  break;##


end if;   
#################
end if;

#xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
end if; end do;
end if;
if affichage=1 then  print(`xxxxxxxxxxxxxxxxxxxxx  Paire n°`, i ,` fait  xxxxxxxxxxxxxxxxxxxxxx`,AF2LLL[41],AF2LLL[42],AF2LLL[43],AF2LLL[44]);
                     end if;
end do;

if [op(1..16,AF2LLL)]=[1,1,2,1,3,1,4,1,5,1,6,1,7,1,8,1] then ok:=1; end if;
[ok,Aalgo,AF2LLL];
end proc:

>