{"id":2085,"date":"2024-06-25T18:22:27","date_gmt":"2024-06-25T21:22:27","guid":{"rendered":"https:\/\/matematicasaomiguel.com.br\/?page_id=2085"},"modified":"2024-08-31T21:18:45","modified_gmt":"2024-09-01T00:18:45","slug":"jodomastermind","status":"publish","type":"page","link":"https:\/\/matematicasaomiguel.com.br\/?page_id=2085","title":{"rendered":"Jogo senha"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-page\" data-elementor-id=\"2085\" class=\"elementor elementor-2085\">\n\t\t\t\t<div class=\"elementor-element elementor-element-98b313c e-flex e-con-boxed e-con e-parent\" data-id=\"98b313c\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-2bbd3fb elementor-widget elementor-widget-html\" data-id=\"2bbd3fb\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<!DOCTYPE html>\r\n<html lang=\"pt-BR\">\r\n<head>\r\n    <meta charset=\"UTF-8\">\r\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\r\n    <title>Jogo senha!<\/title>\r\n    <style>\r\n        body {\r\n            font-family: sans-serif;\r\n            text-align: center;\r\n            margin: 20px;\r\n        }\r\n\r\n        h1 {\r\n            font-size: 1.5em;\r\n        }\r\n\r\n        #jogo {\r\n            margin: 20px auto;\r\n            max-width: 600px;\r\n            display: flex;\r\n            flex-direction: column;\r\n            align-items: center;\r\n        }\r\n\r\n        .tentativas-container {\r\n            width: 100%;\r\n            margin-top: 20px;\r\n            max-height: 300px;\r\n            overflow-y: auto;\r\n        }\r\n\r\n        .tentativa {\r\n            display: flex;\r\n            justify-content: space-between;\r\n            align-items: center;\r\n            margin-bottom: 10px;\r\n            padding: 10px;\r\n            border: 1px solid #ccc;\r\n        }\r\n\r\n        .chute {\r\n            display: flex;\r\n            align-items: center;\r\n            justify-content: center;\r\n            margin-bottom: 10px;\r\n        }\r\n\r\n        .chute input {\r\n            width: 30px;\r\n            height: 30px;\r\n            text-align: center;\r\n            margin: 0 5px;\r\n        }\r\n\r\n        .feedback {\r\n            display: flex;\r\n            align-items: center;\r\n        }\r\n\r\n        .bola {\r\n            width: 20px;\r\n            height: 20px;\r\n            border-radius: 50%;\r\n            margin: 2px;\r\n        }\r\n\r\n        .preto {\r\n            background-color: black;\r\n        }\r\n\r\n        .branco {\r\n            background-color: white;\r\n            border: 1px solid #ccc;\r\n        }\r\n\r\n        button {\r\n            margin-top: 10px;\r\n            padding: 10px 20px;\r\n            cursor: pointer;\r\n            font-size: 1em;\r\n        }\r\n    <\/style>\r\n<\/head>\r\n<body>\r\n    <h2>Dica:bola preta o n\u00famero est\u00e1 na posi\u00e7\u00e3o correta, bola branca o n\u00famero pertence a senha mas n\u00e3o est\u00e1 no lugar certo: Desvende a senha.<\/h2>\r\n\r\n    <div id=\"jogo\">\r\n        <div class=\"tentativas-container\" id=\"tentativas\">\r\n            <!-- Aqui ser\u00e3o inseridas dinamicamente as tentativas -->\r\n        <\/div>\r\n\r\n        <div class=\"chute\">\r\n            <input type=\"number\" min=\"0\" max=\"9\" maxlength=\"1\">\r\n            <input type=\"number\" min=\"0\" max=\"9\" maxlength=\"1\">\r\n            <input type=\"number\" min=\"0\" max=\"9\" maxlength=\"1\">\r\n            <input type=\"number\" min=\"0\" max=\"9\" maxlength=\"1\">\r\n        <\/div>\r\n        <button onclick=\"adicionarTentativa()\">Conferir Senha<\/button>\r\n    <\/div>\r\n\r\n    <script>\r\n        const numerosPossiveis = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];\r\n        let codigoSecreto = gerarCodigoSecreto();\r\n        let tentativasRestantes = 10;\r\n\r\n        function gerarCodigoSecreto() {\r\n            let codigo = [];\r\n            while (codigo.length < 4) {\r\n                const indiceAleatorio = Math.floor(Math.random() * numerosPossiveis.length);\r\n                const numero = numerosPossiveis.splice(indiceAleatorio, 1)[0];\r\n                codigo.push(numero);\r\n            }\r\n            return codigo;\r\n        }\r\n\r\n        function adicionarTentativa() {\r\n            if (tentativasRestantes > 0) {\r\n                const chute = [];\r\n                const inputs = document.querySelectorAll('.chute input');\r\n                inputs.forEach(input => chute.push(Number(input.value)));\r\n                \r\n                \/\/ Verificar se o chute tem 4 n\u00fameros\r\n                if (chute.length === 4 && chute.every(num => num >= 0 && num <= 9)) {\r\n                    const feedback = compararCodigoChute(codigoSecreto, chute);\r\n                    exibirTentativa(chute, feedback);\r\n                    tentativasRestantes--;\r\n\r\n                    if (feedback.posicoesCorretas === 4) {\r\n                        alert(`Parab\u00e9ns! Voc\u00ea desvendou o c\u00f3digo em ${10 - tentativasRestantes} tentativas.`);\r\n                        reiniciarJogo();\r\n                    } else {\r\n                        if (tentativasRestantes === 0) {\r\n                            alert('Voc\u00ea n\u00e3o conseguiu desvendar o c\u00f3digo.');\r\n                            reiniciarJogo();\r\n                        }\r\n                    }\r\n\r\n                    \/\/ Limpar os inputs do chute ap\u00f3s adicionar a tentativa\r\n                    inputs.forEach(input => input.value = '');\r\n                } else {\r\n                    alert('Digite exatamente 4 n\u00fameros v\u00e1lidos (0-9).');\r\n                }\r\n            }\r\n        }\r\n\r\n        function compararCodigoChute(codigoSecreto, chute) {\r\n            let posicoesCorretas = 0;\r\n            let numerosCorretos = 0;\r\n            const codigoSecretoCopy = codigoSecreto.slice();\r\n            const chuteCopy = chute.slice();\r\n\r\n            \/\/ Primeira passagem: verificar posi\u00e7\u00f5es corretas\r\n            for (let i = 0; i < codigoSecretoCopy.length; i++) {\r\n                if (codigoSecretoCopy[i] === chuteCopy[i]) {\r\n                    posicoesCorretas++;\r\n                    codigoSecretoCopy[i] = null; \/\/ Marcar como j\u00e1 verificado\r\n                    chuteCopy[i] = null; \/\/ Marcar como j\u00e1 verificado\r\n                }\r\n            }\r\n\r\n            \/\/ Segunda passagem: verificar n\u00fameros corretos em posi\u00e7\u00f5es incorretas\r\n            for (let i = 0; i < chuteCopy.length; i++) {\r\n                if (chuteCopy[i] !== null && codigoSecretoCopy.includes(chuteCopy[i])) {\r\n                    numerosCorretos++;\r\n                    codigoSecretoCopy[codigoSecretoCopy.indexOf(chuteCopy[i])] = null; \/\/ Marcar como j\u00e1 verificado\r\n                    chuteCopy[i] = null; \/\/ Marcar como j\u00e1 verificado\r\n                }\r\n            }\r\n\r\n            return { posicoesCorretas, numerosCorretos };\r\n        }\r\n\r\n        function exibirTentativa(chute, feedback) {\r\n            const tentativasDiv = document.getElementById('tentativas');\r\n            const divTentativa = document.createElement('div');\r\n            divTentativa.classList.add('tentativa');\r\n\r\n            const divChute = document.createElement('div');\r\n            divChute.classList.add('chute');\r\n            chute.forEach(num => {\r\n                const span = document.createElement('span');\r\n                span.textContent = num;\r\n                divChute.appendChild(span);\r\n            });\r\n\r\n            const divFeedback = document.createElement('div');\r\n            divFeedback.classList.add('feedback');\r\n            for (let i = 0; i < feedback.posicoesCorretas; i++) {\r\n                const bola = document.createElement('div');\r\n                bola.classList.add('bola', 'preto');\r\n                divFeedback.appendChild(bola);\r\n            }\r\n            for (let i = 0; i < feedback.numerosCorretos - feedback.posicoesCorretas; i++) {\r\n                const bola = document.createElement('div');\r\n                bola.classList.add('bola', 'branco');\r\n                divFeedback.appendChild(bola);\r\n            }\r\n\r\n            divTentativa.appendChild(divChute);\r\n            divTentativa.appendChild(divFeedback);\r\n            tentativasDiv.prepend(divTentativa); \/\/ Adiciona a nova tentativa no in\u00edcio\r\n        }\r\n\r\n        function reiniciarJogo() {\r\n            codigoSecreto = gerarCodigoSecreto();\r\n            tentativasRestantes = 10;\r\n            document.getElementById('tentativas').innerHTML = ''; \/\/ Limpa as tentativas\r\n        }\r\n    <\/script>\r\n<\/body>\r\n<\/html>\r\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Jogo senha! Dica:bola preta o n\u00famero est\u00e1 na posi\u00e7\u00e3o correta, bola branca o n\u00famero pertence a senha mas n\u00e3o est\u00e1 [&hellip;]<\/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":"","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":"","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-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":"","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-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":"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":""},"mobile":{"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":""}},"footnotes":""},"class_list":["post-2085","page","type-page","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/matematicasaomiguel.com.br\/index.php?rest_route=\/wp\/v2\/pages\/2085","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/matematicasaomiguel.com.br\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/matematicasaomiguel.com.br\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/matematicasaomiguel.com.br\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/matematicasaomiguel.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2085"}],"version-history":[{"count":90,"href":"https:\/\/matematicasaomiguel.com.br\/index.php?rest_route=\/wp\/v2\/pages\/2085\/revisions"}],"predecessor-version":[{"id":3935,"href":"https:\/\/matematicasaomiguel.com.br\/index.php?rest_route=\/wp\/v2\/pages\/2085\/revisions\/3935"}],"wp:attachment":[{"href":"https:\/\/matematicasaomiguel.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2085"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}