Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- P = 0; S = 0;
- function f(a,b,c,d,n=24,L='',g='') {
- if (L.match(a+b+c+d)) return 0;
- if (!--n) return S+=6*4;
- L += ' ' + a+b+c+d;
- if (++P % 1e6 == 0) console.log(g, S);
- return f(b,a,c,d,n,L,g+'1') +
- f(a,c,b,d,n,L,g+'2') +
- f(a,b,d,c,n,L,g+'3') +
- f(c,b,a,d,n,L,g+'4') +
- f(a,d,c,b,n,L,g+'5') +
- f(d,b,c,a,n,L,g+'6');
- }
- f('1','4','2','3',22,'1234 1243','')
- P = 0; S = 0;
- function f(a,b,c,d,n=24,L='',g='') {
- if (L.match(a+b+c+d)) return 0;
- if (!--n) return S+=6;
- L += ' ' + a+b+c+d;
- if (++P % 1e6 == 0) console.log(g, S);
- return f(b,a,c,d,n,L,g+'1') +
- f(a,c,b,d,n,L,g+'2') +
- f(a,b,d,c,n,L,g+'3') +
- f(c,b,a,d,n,L,g+'4') +
- f(a,d,c,b,n,L,g+'5') +
- f(d,b,c,a,n,L,g+'6');
- }
- f('2','1','4','3',22,'1234 1243','')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement