{"id":235,"date":"2025-01-06T09:10:56","date_gmt":"2025-01-06T09:10:56","guid":{"rendered":"https:\/\/smallmoon.net\/?p=235"},"modified":"2025-01-07T03:00:52","modified_gmt":"2025-01-07T03:00:52","slug":"schulte-grid","status":"publish","type":"post","link":"https:\/\/smallmoon.net\/?p=235","title":{"rendered":"Schulte Grid"},"content":{"rendered":"\n<!DOCTYPE html>\n<html>\n<head>\n    <title>\u8212\u5c14\u7279\u65b9\u683c\u6e38\u620f<\/title>\n    <meta charset=\"utf-8\" \/>\n    <style>\n        table {\n            border-collapse: collapse;\n            margin: 0 auto;\n        }\n        td {\n            width: 40px;\n            height: 40px;\n            border: 1px solid #000;\n            text-align: center;\n            font-size: 20px;\n            cursor: pointer;\n        }\n        #start {\n            width: 160px;\n            height: 80px;\n            line-height: 40px;\n            text-align: center;\n            font-size: 20px;\n            cursor: pointer;\n            margin-top: 20px;\n        }\n    <\/style>\n<\/head>\n<body>\n    <p>\u8bf7\u8f93\u5165\u6e38\u620f\u96be\u5ea6\uff08\u8f93\u51652-18\u4e4b\u95f4\u7684\u6570\u5b57\uff09\uff1a<input type=\"text\" id=\"num\" \/><\/p>\n    <p><input type=\"button\" value=\"\u5f00\u59cb\u6e38\u620f\" id=\"start\" \/><\/p>\n    <table id=\"table\"><\/table>\n    <div>\u5b8c\u6210\u6e38\u620f\u7528\u65f6\uff1a<span id=\"time\">0<\/span>\u79d2<\/div>\n    <script>\n        var num = document.getElementById(\"num\");\n        var start = document.getElementById(\"start\");\n        var table = document.getElementById(\"table\");\n        var time = document.getElementById(\"time\");\n        var arr = [];\n        var clickNum = 0;\n        var startTime = 0;\n        var endTime = 0;\n        start.onclick = function(){\n            if(num.value == \"\"){\n                alert(\"\u8bf7\u8f93\u5165\u6e38\u620f\u89c4\u6a21\uff01\");\n            }else{\n                startTime = new Date().getTime();\n                createTable();\n                randomNum();\n            }\n        }\n        \/\/ \u751f\u6210\u8868\u683c\n        function createTable(){\n            table.innerHTML = \"\";\n            for(var i = 0; i < num.value; i++){\n                var tr = document.createElement(\"tr\");\n                for(var j = 0; j < num.value; j++){\n                    var td = document.createElement(\"td\");\n                    tr.appendChild(td);\n                }\n                table.appendChild(tr);\n            }\n        }\n        \/\/ \u968f\u673a\u6570\u5b57\n        function randomNum(){\n            arr.length = 0;\n            for(var i = 0; i < num.value * num.value; i++){\n                arr.push(i + 1);\n            }\n            arr.sort(function(){\n                return Math.random() - 0.5;\n            });\n            for(var i = 0; i < table.children.length; i++){\n                for(var j = 0; j < table.children[i].children.length; j++){\n                    table.children[i].children[j].innerHTML = arr[i * num.value + j];\n                }\n            }\n            clickNum = 0;\n            table.onclick = function(e){\n                if(e.target.tagName == \"TD\"){\n                    if(e.target.innerHTML == clickNum + 1){\n                        e.target.style.background = \"#ff0\";\n                        clickNum++;\n                        if(clickNum == num.value * num.value){\n                            endTime = new Date().getTime();\n                            time.innerHTML = (endTime - startTime) \/ 1000;\n                        }\n                    }\n                }\n            }\n        }\n    <\/script>\n<\/body>\n<\/html>\n","protected":false},"excerpt":{"rendered":"<p>\u8212\u5c14\u7279\u65b9\u683c\u6e38\u620f \u8bf7\u8f93\u5165\u6e38\u620f\u96be\u5ea6\uff08\u8f93\u51652-18\u4e4b\u95f4\u7684\u6570\u5b57\uff09\uff1a \u5b8c\u6210\u6e38\u620f\u7528\u65f6\uff1a0\u79d2<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[9],"class_list":["post-235","post","type-post","status-publish","format-standard","hentry","category-game","tag-schulte-grid"],"_links":{"self":[{"href":"https:\/\/smallmoon.net\/index.php?rest_route=\/wp\/v2\/posts\/235","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/smallmoon.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/smallmoon.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/smallmoon.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/smallmoon.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=235"}],"version-history":[{"count":2,"href":"https:\/\/smallmoon.net\/index.php?rest_route=\/wp\/v2\/posts\/235\/revisions"}],"predecessor-version":[{"id":254,"href":"https:\/\/smallmoon.net\/index.php?rest_route=\/wp\/v2\/posts\/235\/revisions\/254"}],"wp:attachment":[{"href":"https:\/\/smallmoon.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=235"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/smallmoon.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=235"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/smallmoon.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}