{"id":202100,"student_id":3463,"content":"{\"html\":\"\\n\u003chtml\u003e\\n\u003chead\u003e\\n \u003ctitle\u003eDocument\u003c/title\u003e\\n \u003cscript src=\\\"https://code.jquery.com/jquery-3.5.1.min.js\\\"\u003e\u003c/script\u003e\\n\u003c/head\u003e\\n\u003cbody\u003e\\n \u003ch1\u003e1A2B 推理遊戲\u003c/h1\u003e\\n \u003ctextarea id=\\\"textarea\\\" disabled autocomplete=\\\"off\\\" autocorrect=\\\"off\\\" autocapitalize=\\\"off\\\" spellcheck=\\\"false\\\"\u003e\\n========== 遊戲規則說明 ==========\\n\\n密碼是由 4 個不同的數字組成\\n每次猜完,電腦會返回 A、B 兩個數字結果\\nA 表示數字猜對 且 位置正確\\nB 表示數字猜對 但 位置錯誤\\n \u003c/textarea\u003e\\n \u003cbr/\u003e\\n \u003cbutton id=\\\"start\\\" class=\\\"green\\\"\u003e開始新的遊戲\u003c/button\u003e\\n \u003cbutton id=\\\"guess\\\" class=\\\"yellow\\\"\u003e猜密碼\u003c/button\u003e\\n \u003cbutton id=\\\"crack\\\" class=\\\"red\\\"\u003e自動破解\u003c/button\u003e\\n\u003c/body\u003e\\n\u003c/html\u003e\",\"css\":\"body {\\n text-align: center;\\n background-color: #25313e;\\n font-family: Arial;\\n}\\n\\nh1 {\\n color: #607489;\\n margin: 20px;\\n}\\n\\ntextarea {\\n width: 350px;\\n height: 350px;\\n padding: 15px;\\n border: 1px solid #aaa;\\n border-radius: 3px;\\n color: #ccc;\\n box-shadow: 0 0.25rem 0.5rem #12181e;\\n background-color: #191919;\\n text-align: center;\\n font-size: 16px;\\n line-height: 20px;\\n font-family: Monospace;\\n}\\n\\nbutton {\\n padding: 10px;\\n color: #eee;\\n margin: 10px 5px;\\n border: 1px solid #aaa;\\n border-radius: 3px;\\n box-shadow: 0 0.25rem 0.5rem #12181e;\\n font-size: 1rem;\\n cursor: pointer;\\n}\\n\\nbutton.red {\\n background-color: #fc4048;\\n}\\n\\nbutton.yellow {\\n background-color: #fd9409;\\n}\\n\\nbutton.green {\\n background-color: #1fc3b2;\\n}\",\"js\":\"$('#start').click(start); //開始遊戲\\n$('#guess').click(function () {\\n var str = prompt('輸入四位不重複數字');\\n guess(str);\\n});\\n$('#crack').click(crack);\\nvar answer = undefined;\\nvar count = 0;\\nstart();\\nfunction start () {\\n $('#textarea').append('\\\\n========== 開始新的遊戲 ==========\\\\n\\\\n');\\n count = 0; //歸零紀錄猜的次數\\n var list = getList();\\n\\n // var rand = Math.floor(Math.random()*list.length)\\n // answer = list[rand]\\n var rand = Math.floor(Math.random()*list.length)\\n answer = list[rand]\\n\\n}\\n\\nfunction guess (str) {\\n var result = diff(str, answer);\\n count++\\n $('textarea').append(`${count} 猜${str} A:${result.a} B:${result.b} \\\\n`)\\n if (result.a == 4) {\\n $('textarea').append('\\\\猜對了!')\\n }\\n return result;\\n}\\n\\n\\nfunction getList () {\\n var list = [];\\n for (var i = 123; i \u003c 9877; i++) {\\n var t = i.toString()\\n if (t.length \u003c 4) {\\n t = '0' + t\\n }\\n if (t[0] != t[1] \u0026\u0026 t[0] != t[2] \u0026\u0026 t[0] != t[3] \u0026\u0026 t[2] != t[1] \u0026\u0026 t[1] != t[3] \u0026\u0026 t[2] != t[3]) {\\n list.push(t)\\n }\\n }\\n return list;\\n}\\nfunction diff (s1, s2) {\\n var a = 0;\\n var b = 0;\\n for (var i = 0; i \u003c 4; i++) {\\n var idx = s2.indexOf(s1[i])\\n if (idx != -1) {\\n if (idx == i) {\\n a++\\n } else {\\n b++\\n }\\n }\\n }\\n return {\\n a: a, b: b\\n }\\n}\\n\\nvar result2;\\nvar g;\\nvar result;\\nvar list;\\n\\nfunction crack () {\\n list = getList()\\n console.log(answer)\\n while(true) {\\n g = list.pop()\\n console.log(list.length)\\n console.log(result)\\n result = guess(g)\\n if (result.a == 4) {\\n break;\\n }\\n for (var j = 0; j \u003c list.length; j++) {\\n \\n \\n result2 = diff(list[j], g)\\n if ((result.a != result2.a) || (result.b != result2.b)) {\\n list.splice(j, 1)\\n j--\\n }\\n \\n\\n }\\n\\n }\\n}\"}","created_at":"2020-11-07T13:42:14.888+08:00","updated_at":"2021-10-15T10:38:25.245+08:00","name":"破解 1A2B 推理遊戲(預設版) 副本","language":"web","screenshot":{"url":"https://cdn4.koding.school/uploads/project/screenshot/202100/2886c4f4db16f5cbe1f0694a18f62fb0.jpg"},"parent_id":160544,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":131,"hashid":"6rps984d4","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
前往網站頁面
1:1:1
1:1
full
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦