Advertisement
Guest User

Untitled

a guest
May 7th, 2024
17
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. P = 0; S = 0;
  2. function f(a,b,c,d,n=24,L='',g='') {
  3.     if (L.match(a+b+c+d)) return 0;
  4.     if (!--n) return S+=6*4;
  5.     L += ' ' + a+b+c+d;
  6.     if (++P % 1e6 == 0) console.log(g, S);
  7.     return f(b,a,c,d,n,L,g+'1') +
  8.            f(a,c,b,d,n,L,g+'2') +
  9.            f(a,b,d,c,n,L,g+'3') +
  10.            f(c,b,a,d,n,L,g+'4') +
  11.            f(a,d,c,b,n,L,g+'5') +
  12.            f(d,b,c,a,n,L,g+'6');
  13. }
  14. f('1','4','2','3',22,'1234 1243','')
  15.  
  16.  
  17. P = 0; S = 0;
  18. function f(a,b,c,d,n=24,L='',g='') {
  19.     if (L.match(a+b+c+d)) return 0;
  20.     if (!--n) return S+=6;
  21.     L += ' ' + a+b+c+d;
  22.     if (++P % 1e6 == 0) console.log(g, S);
  23.     return f(b,a,c,d,n,L,g+'1') +
  24.            f(a,c,b,d,n,L,g+'2') +
  25.            f(a,b,d,c,n,L,g+'3') +
  26.            f(c,b,a,d,n,L,g+'4') +
  27.            f(a,d,c,b,n,L,g+'5') +
  28.            f(d,b,c,a,n,L,g+'6');
  29. }
  30. f('2','1','4','3',22,'1234 1243','')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement