{"id":631,"date":"2025-08-19T10:19:53","date_gmt":"2025-08-19T01:19:53","guid":{"rendered":"https:\/\/momospace.org\/?page_id=631"},"modified":"2025-08-25T12:16:55","modified_gmt":"2025-08-25T03:16:55","slug":"%ed%8d%bc%ec%a6%90-%ea%b2%8c%ec%9e%84%ec%a1%b4","status":"publish","type":"page","link":"https:\/\/momospace.org\/?page_id=631","title":{"rendered":"\ud37c\uc990 \uac8c\uc784\uc874"},"content":{"rendered":"\n<!DOCTYPE html>\n<html lang=\"ko\">\n<head>\n    <meta charset=\"UTF-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <title>\uc2a4\ub3c4\ucfe0 \uac8c\uc784<\/title>\n    <style>\n        @import url('https:\/\/fonts.googleapis.com\/css2?family=Inter:wght@400;700&display=swap');\n\n        body {\n            font-family: 'Inter', sans-serif;\n            background-color: #f0f4f8;\n            display: flex;\n            justify-content: center;\n            align-items: center;\n            min-height: 100vh;\n            margin: 0;\n            color: #1e293b;\n            padding: 1rem;\n        }\n\n        .game-container {\n            background-color: #ffffff;\n            border-radius: 1rem;\n            box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);\n            padding: 1rem;\n            text-align: center;\n            width: 100%;\n            max-width: 550px;\n            box-sizing: border-box;\n            border: 2px solid #e2e8f0;\n        }\n\n        h1 {\n            color: #334155;\n            font-size: clamp(1.2rem, 5vw, 1.8rem);\n            margin-bottom: 1rem;\n            font-weight: 700;\n        }\n\n        #sudoku-board {\n            display: grid;\n            grid-template-columns: repeat(9, 1fr);\n            grid-template-rows: repeat(9, 1fr);\n            width: 100%;\n            aspect-ratio: 1 \/ 1;\n            margin: 0 auto 1rem;\n            border: 3px solid #334155;\n            box-sizing: border-box;\n            max-width: 95vw;\n        }\n\n        .cell {\n            border: 1px solid #cbd5e1;\n            display: flex;\n            justify-content: center;\n            align-items: center;\n            font-size: clamp(0.8rem, 2.8vw, 1.2rem);\n            font-weight: 600;\n            box-sizing: border-box;\n            user-select: none;\n        }\n\n        .cell.fixed {\n            background-color: #e2e8f0;\n            color: #334155;\n            font-weight: 700;\n        }\n\n        .cell.user-input {\n            background-color: #f8fafc;\n            color: #2563eb;\n            cursor: pointer;\n        }\n\n        .cell.error {\n            background-color: #fecaca;\n            color: #b91c1c;\n        }\n        .cell.selected {\n            background-color: #d1e5ff;\n        }\n\n        .cell:nth-child(3n) { border-right: 2px solid #334155; }\n        .cell:nth-child(9n) { border-right: 1px solid #cbd5e1; }\n        .cell:nth-child(n+19):nth-child(-n+27),\n        .cell:nth-child(n+46):nth-child(-n+54) { border-bottom: 2px solid #334155; }\n\n        \/* \ubc84\ud2bc \uc601\uc5ed *\/\n        .controls {\n            display: flex;\n            justify-content: center;\n            flex-wrap: wrap;\n            gap: 0.5rem;\n            margin-bottom: 1rem;\n        }\n        .control-button {\n            padding: 0.6rem 1rem;\n            background-color: #4a5568;\n            color: white;\n            border: none;\n            border-radius: 0.5rem;\n            font-size: clamp(0.9rem, 3vw, 1rem);\n            font-weight: 600;\n            cursor: pointer;\n            flex: 1 1 30%;\n            min-width: 90px;\n            transition: background-color 0.2s;\n        }\n        .control-button:hover {\n            background-color: #2d3748;\n        }\n\n        \/* \uc22b\uc790\ud328\ub4dc *\/\n        .number-pad {\n            display: grid;\n            grid-template-columns: repeat(5, 1fr);\n            gap: 0.4rem;\n            margin-top: 0.8rem;\n        }\n        .number-pad button {\n            padding: 0.7rem;\n            font-size: 1rem;\n            font-weight: 600;\n            border: none;\n            border-radius: 0.4rem;\n            background-color: #2563eb;\n            color: white;\n            cursor: pointer;\n            transition: 0.2s;\n        }\n        .number-pad button:hover {\n            background-color: #1d4ed8;\n        }\n\n        #message {\n            min-height: 1.5rem;\n            font-size: clamp(0.9rem, 3vw, 1rem);\n            font-weight: 600;\n        }\n    <\/style>\n<\/head>\n<body>\n\n<div class=\"game-container\">\n    <h1>\uc2a4\ub3c4\ucfe0 \ud37c\uc990 \uac8c\uc784<\/h1>\n    <div id=\"sudoku-board\"><\/div>\n    <div class=\"controls\">\n        <!-- onclick \uc18d\uc131 \uc81c\uac70, id \ucd94\uac00 -->\n        <button id=\"check-btn\" class=\"control-button\">\ud655\uc778<\/button>\n        <button id=\"new-game-btn\" class=\"control-button\">\uc0c8 \uac8c\uc784<\/button>\n        <button id=\"clear-btn\" class=\"control-button\">\uc9c0\uc6b0\uae30<\/button>\n    <\/div>\n    <div id=\"number-pad-container\" class=\"number-pad\"> <!-- \ucee8\ud14c\uc774\ub108\uc5d0 ID \ubd80\uc5ec -->\n        <!-- onclick \uc18d\uc131 \uc81c\uac70, data-number \uc18d\uc131 \ucd94\uac00 -->\n        <button data-number=\"1\">1<\/button>\n        <button data-number=\"2\">2<\/button>\n        <button data-number=\"3\">3<\/button>\n        <button data-number=\"4\">4<\/button>\n        <button data-number=\"5\">5<\/button>\n        <button data-number=\"6\">6<\/button>\n        <button data-number=\"7\">7<\/button>\n        <button data-number=\"8\">8<\/button>\n        <button data-number=\"9\">9<\/button>\n        <button data-number=\"0\">\uc9c0\uc6c0<\/button>\n    <\/div>\n    <div id=\"message\"><\/div>\n<\/div>\n\n<script>\n\/\/ \ubcc0\uacbd\uc810 1: window.onload \ub300\uc2e0 DOMContentLoaded \uc774\ubca4\ud2b8 \ub9ac\uc2a4\ub108 \uc0ac\uc6a9\ndocument.addEventListener('DOMContentLoaded', function() {\n    const boardElement = document.getElementById('sudoku-board');\n    const messageElement = document.getElementById('message');\n    const boardSize = 9;\n    let board = [];\n    let fixedCells = [];\n    let selectedCell = null;\n\n    \/\/ \ubcf4\ub4dc \uc0dd\uc131 \ubc0f \ucd08\uae30\ud654\n    function generateBoard() {\n        boardElement.innerHTML = '';\n        board = Array(boardSize).fill(null).map(() => Array(boardSize).fill(0));\n        fixedCells = [];\n\n        solveSudoku();\n\n        let numCellsToShow = 35 + Math.floor(Math.random() * 5);\n        let positions = [];\n        for (let i = 0; i < boardSize * boardSize; i++) positions.push(i);\n        shuffle(positions);\n\n        for (let i = 0; i < numCellsToShow; i++) {\n            const pos = positions[i];\n            const row = Math.floor(pos \/ boardSize);\n            const col = pos % boardSize;\n            fixedCells.push({ row, col, value: board[row][col] });\n        }\n\n        for (let i = 0; i < boardSize; i++) {\n            for (let j = 0; j < boardSize; j++) {\n                const cell = document.createElement('div');\n                cell.className = 'cell';\n                const isFixed = fixedCells.some(c => c.row === i && c.col === j);\n                if (isFixed) {\n                    cell.classList.add('fixed');\n                    cell.textContent = board[i][j];\n                } else {\n                    cell.classList.add('user-input');\n                    cell.dataset.row = i;\n                    cell.dataset.col = j;\n                    cell.addEventListener('click', () => selectCell(cell));\n                }\n                boardElement.appendChild(cell);\n            }\n        }\n        messageElement.textContent = '\uac8c\uc784\uc744 \uc2dc\uc791\ud558\uc138\uc694!';\n        messageElement.style.color = '#475569';\n    }\n\n    \/\/ \ubcf4\ub4dc \ud574\uacb0 \uc54c\uace0\ub9ac\uc998 (\uc774\ud558 \ub3d9\uc77c)\n    function solveSudoku() {\n        const grid = Array(boardSize).fill(null).map(() => Array(boardSize).fill(0));\n        fillGrid(grid);\n        board = grid;\n    }\n    function fillGrid(grid) {\n        let emptyCell = findEmpty(grid);\n        if (!emptyCell) return true;\n        const [row, col] = emptyCell;\n        let numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9];\n        shuffle(numbers);\n        for (let num of numbers) {\n            if (isValid(grid, row, col, num)) {\n                grid[row][col] = num;\n                if (fillGrid(grid)) return true;\n                grid[row][col] = 0;\n            }\n        }\n        return false;\n    }\n    function findEmpty(grid) {\n        for (let row = 0; row < boardSize; row++) {\n            for (let col = 0; col < boardSize; col++) {\n                if (grid[row][col] === 0) return [row, col];\n            }\n        }\n        return null;\n    }\n    function isValid(grid, row, col, num) {\n        for (let i = 0; i < boardSize; i++) if (grid[row][i] === num) return false;\n        for (let i = 0; i < boardSize; i++) if (grid[i][col] === num) return false;\n        const boxRow = Math.floor(row \/ 3) * 3;\n        const boxCol = Math.floor(col \/ 3) * 3;\n        for (let i = 0; i < 3; i++) for (let j = 0; j < 3; j++) {\n            if (grid[boxRow + i][boxCol + j] === num) return false;\n        }\n        return true;\n    }\n    function shuffle(array) {\n        for (let i = array.length - 1; i > 0; i--) {\n            const j = Math.floor(Math.random() * (i + 1));\n            [array[i], array[j]] = [array[j], array[i]];\n        }\n    }\n\n    \/\/ \uc140 \uc120\ud0dd\n    function selectCell(cell) {\n        if (selectedCell) selectedCell.classList.remove('selected');\n        selectedCell = cell;\n        selectedCell.classList.add('selected');\n        messageElement.textContent = '';\n    }\n\n    \/\/ \uc22b\uc790\ud328\ub4dc \uc785\ub825 \ud568\uc218\n    function inputNumber(num) {\n        if (selectedCell && selectedCell.classList.contains('user-input')) {\n            if (num === 0) {\n                selectedCell.textContent = '';\n            } else {\n                selectedCell.textContent = num;\n            }\n            checkErrors();\n        }\n    }\n    \n    \/\/ \uc624\ub958 \uccb4\ud06c\n    function checkErrors() {\n        const cells = document.querySelectorAll('.user-input');\n        cells.forEach(cell => {\n            const row = parseInt(cell.dataset.row);\n            const col = parseInt(cell.dataset.col);\n            const value = cell.textContent === '' ? 0 : parseInt(cell.textContent);\n            cell.classList.remove('error');\n            if (value !== 0 && board[row][col] !== value) {\n                cell.classList.add('error');\n            }\n        });\n    }\n\n    \/\/ \uc815\ub2f5 \ud655\uc778\n    function checkSolution() {\n        const cells = document.querySelectorAll('.user-input');\n        let isCorrect = true;\n        let isComplete = true;\n        cells.forEach(cell => {\n            const row = parseInt(cell.dataset.row);\n            const col = parseInt(cell.dataset.col);\n            const value = parseInt(cell.textContent);\n            if (isNaN(value)) {\n                isComplete = false;\n            }\n            if (isNaN(value) || value !== board[row][col]) {\n                isCorrect = false;\n            }\n        });\n\n        if (isCorrect && isComplete) {\n            messageElement.textContent = '\ucd95\ud558\ud569\ub2c8\ub2e4! \ud37c\uc990\uc744 \uc644\uc131\ud588\uc5b4\uc694! \ud83c\udf89';\n            messageElement.style.color = '#10b981';\n        } else {\n            messageElement.textContent = '\uc544\uc9c1 \ud2c0\ub9b0 \uacf3\uc774 \uc788\uac70\ub098 \ube48 \uce78\uc774 \uc788\uc5b4\uc694. \ud83e\udd14';\n            messageElement.style.color = '#ef4444';\n        }\n    }\n\n    \/\/ \ubcf4\ub4dc \uc9c0\uc6b0\uae30\n    function clearBoard() {\n        const cells = document.querySelectorAll('.user-input');\n        cells.forEach(cell => {\n            cell.textContent = '';\n            cell.classList.remove('error');\n        });\n        if (selectedCell) {\n            selectedCell.classList.remove('selected');\n            selectedCell = null;\n        }\n        messageElement.textContent = '\uc785\ub825\ud55c \uc22b\uc790\ub97c \ubaa8\ub450 \uc9c0\uc6e0\uc2b5\ub2c8\ub2e4.';\n        messageElement.style.color = '#475569';\n    }\n\n    \/\/ \ubcc0\uacbd\uc810 2: HTML\uc758 onclick\uc744 \uc81c\uac70\ud558\uace0 JS\uc5d0\uc11c \uc774\ubca4\ud2b8 \ub9ac\uc2a4\ub108\ub97c \ub4f1\ub85d\n    document.getElementById('check-btn').addEventListener('click', checkSolution);\n    document.getElementById('new-game-btn').addEventListener('click', generateBoard);\n    document.getElementById('clear-btn').addEventListener('click', clearBoard);\n\n    \/\/ \uc22b\uc790\ud328\ub4dc \uc774\ubca4\ud2b8 \ub9ac\uc2a4\ub108 (\uc774\ubca4\ud2b8 \uc704\uc784 \ubc29\uc2dd \uc0ac\uc6a9)\n    document.getElementById('number-pad-container').addEventListener('click', function(e) {\n        if (e.target.tagName === 'BUTTON' && e.target.dataset.number) {\n            const num = parseInt(e.target.dataset.number);\n            inputNumber(num);\n        }\n    });\n\n    \/\/ \ud0a4\ubcf4\ub4dc \uc785\ub825 \uc9c0\uc6d0\n    document.addEventListener('keydown', (e) => {\n        if (selectedCell && selectedCell.classList.contains('user-input')) {\n            const key = e.key;\n            if (key >= '1' && key <= '9') {\n                inputNumber(parseInt(key));\n            } else if (key === 'Backspace' || key === 'Delete' || key === '0') {\n                inputNumber(0);\n            }\n        }\n    });\n\n    \/\/ \ucd08\uae30 \ubcf4\ub4dc \uc0dd\uc131\n    generateBoard();\n});\n<\/script>\n\n<\/body>\n<\/html>\n","protected":false},"excerpt":{"rendered":"<p>\uc2a4\ub3c4\ucfe0 \uac8c\uc784 \uc2a4\ub3c4\ucfe0 \ud37c\uc990 \uac8c\uc784 \ud655\uc778 \uc0c8 \uac8c\uc784 \uc9c0\uc6b0\uae30 1 2 3 4 5 6 7 8 9 \uc9c0\uc6c0<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"class_list":["post-631","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/momospace.org\/index.php?rest_route=\/wp\/v2\/pages\/631","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/momospace.org\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/momospace.org\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/momospace.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/momospace.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=631"}],"version-history":[{"count":9,"href":"https:\/\/momospace.org\/index.php?rest_route=\/wp\/v2\/pages\/631\/revisions"}],"predecessor-version":[{"id":750,"href":"https:\/\/momospace.org\/index.php?rest_route=\/wp\/v2\/pages\/631\/revisions\/750"}],"wp:attachment":[{"href":"https:\/\/momospace.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=631"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}