{"id":27186,"student_id":10,"content":"// function hanoi(n, a, b, c) {\n// if(n === 1) {\n// return moveTo(a, c);\n// }\n// hanoi(n - 1, a, c, b);\n// hanoi(1, a, b, c);\n// hanoi(n - 1, b, a, c);\n// }\n \n// hanoi(size, 0, 1, 2);\n\nfunction f (n, a, b, c) {\n \n if (n \u003c= 0) return;\n \n f(n - 1, a, c, b);\n moveTo(a, c);\n f(n - 1, b, a, c);\n}\n\nf(5, 0, 1, 2);","created_at":"2018-04-26T12:25:18.946+08:00","updated_at":"2020-06-01T14:26:36.605+08:00","name":"河內塔","language":"javascript","screenshot":{"url":"/uploads/project/screenshot/27186/89edcce60b8890776f43b51e69f48ea4.jpg"},"parent_id":2,"plugin":"var size = 5;\n\nvar towers = [\n [5, 4, 3, 2, 1],\n [],\n []\n];\n\nforever(function(){\n \n drawTower(100, 300, towers[0]);\n drawTower(300, 300, towers[1]);\n drawTower(500, 300, towers[2]);\n \n});\n\nfunction drawTower (x, y, arr) {\n pen.fillColor = 'black';\n for (var i=0; i\u003carr.length; i++) {\n pen.drawRect(x - arr[i]*15/2, y - i*13, arr[i]*15, 10);\n }\n}\n\nvar stack = [];\nfunction moveTo (a, b) {\n stack.push([a,b]);\n}\n\nvar clock = 0;\nforever(function(){\n clock++;\n if (stack.length \u003e 0 \u0026\u0026 clock % 10 == 0) {\n var action = stack.shift();\n var tmp = towers[action[0]].pop();\n towers[action[1]].push(tmp);\n }\n});\n","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":570,"hashid":"ej9s9nyg","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[]
Orange Apple Learning Platform
My Projects
View Project Page
Export
Remix
Import
Delete
Download Android APP (APK)
Screenshot
繁中
简中
English
日本語
1:1:1
1:1
Full Width
Scan the QRCode below with your phone to install
Or you can
download APK
to this computer
Scan the QRCode below with your phone to install
Or you can
download APK
to this computer