-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
58 lines (54 loc) · 1019 Bytes
/
main.js
File metadata and controls
58 lines (54 loc) · 1019 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
let arr = {
'c3': [],
'c2': [],
'c1': []
}
let c = {
'c1': ['c2', 'c3'],
'c2': ['c1', 'c3'],
'c3': ['c1', 'c2'],
}
function print(n) {
let temp =''
for (let i=n-1;i>=0;i--) {
for (var j of ['c1','c2','c3']) {
temp+=(arr[j][i]||0)+'\t'
}
temp+='\n'
}
console.log(temp)
}
let count = 0
async function fun(n, a , b ,p){
count++
//console.log(count)
//console.log(JSON.stringify(arr))
let m = c[a].indexOf(b)
//console.log(m)
let next
m?next=c[a][0]:next=c[a][1]
//console.log(n,a,b,next)
if (n == 1){
arr[b].push(arr[a].pop())
let {c1,c2,c3}=arr
print(p)
return 1
}
else{
//console.log(n,a,b,next,'else')
await fun(n - 1, a, next,p)
await fun(1,a,b,p)
//console.log(n,a,b,next,'else')
//console.log('after q',n,a,b,next)
await fun(n - 1, next,b,p)
return count
}
}
async function mmm(n){
for(let i=n;i>0;i--)
arr.c1[n-i]=i
print(n)
console.log(await fun(n,'c1','c3',n))
}
//mmm(4)
console.log(document.getElementsByTagName('html')[0].children[0].innerHTML)