{"id":1272,"date":"2026-03-20T13:51:59","date_gmt":"2026-03-20T13:51:59","guid":{"rendered":"https:\/\/entrenacalculo.com\/?page_id=1272"},"modified":"2026-03-23T12:54:03","modified_gmt":"2026-03-23T12:54:03","slug":"resta-enteros","status":"publish","type":"page","link":"https:\/\/entrenacalculo.com\/en\/resta-enteros\/","title":{"rendered":"Integer Subtraction"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-page\" data-elementor-id=\"1272\" class=\"elementor elementor-1272\">\n\t\t\t\t<div class=\"elementor-element elementor-element-fb28b9d e-flex e-con-boxed e-con e-parent\" data-id=\"fb28b9d\" 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-9a09b51 elementor-widget elementor-widget-html\" data-id=\"9a09b51\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t\t<script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/jspdf\/2.5.1\/jspdf.umd.min.js\"><\/script>\r\n<style>\r\n    .juego-fiel-text-Z-container {\r\n        font-family: Arial, sans-serif;\r\n        background-color: #f0f0f0;\r\n        margin: 0;\r\n        padding: 5px;\r\n        border-radius: 10px;\r\n    }\r\n    .juego-fiel-text-Z-container .container {\r\n        max-width: 800px; margin: 0 auto; padding: 10px 15px; background-color: #fff; border-radius: 10px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); text-align: center;\r\n    }\r\n    .juego-fiel-text-Z-container h2 { color: #333; }\r\n    .juego-fiel-text-Z-container .lesson { font-style: italic; color: #666;\r\n        margin: 0 0 10px 0; \/* CAMBIO: margen ajustado *\/\r\n    font-size: 0.9em; \/* CAMBIO: texto ligeramente m\u00e1s peque\u00f1o *\/\r\n    line-height: 1.2; \/* CAMBIO: interlineado m\u00e1s compacto *\/ }\r\n    .juego-fiel-text-Z-container button { margin: 10px; padding: 5px 10px; font-size: 16px; border: none; border-radius: 5px; cursor: pointer; background-color: #007bff; color: #fff; transition: background-color 0.3s ease; }\r\n    .juego-fiel-text-Z-container button:hover { background-color: #0056b3; }\r\n    \r\n    \/* --- ESTILOS VISUALES CORREGIDOS --- *\/\r\n    .juego-fiel-text-Z-container .questions-container {\r\n        display: grid;\r\n        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));\r\n        grid-gap: 5px;\r\n        margin-bottom: 10px;\r\n    }\r\n    .juego-fiel-text-Z-container .question {\r\n        padding: 8px;\r\n        background-color: #f9f9f9;\r\n        border-radius: 5px;\r\n    }\r\n    .juego-fiel-text-Z-container .question p {\r\n    margin: 2px 0;\r\n}\r\n\r\n    \/* --- FIN DE LA CORRECCI\u00d3N --- *\/\r\n\r\n    .juego-fiel-text-Z-container .correct-answer { color: green; font-weight: bold; }\r\n    .juego-fiel-text-Z-container .incorrect-answer { color: red; font-weight: bold; }\r\n    .juego-fiel-text-Z-container .hidden { display: none; }\r\n    .juego-fiel-text-Z-container .error-blink { animation: blink-animation-fiel-Z 0.5s infinite alternate; }\r\n    @keyframes blink-animation-fiel-Z { from { background-color: #ff9999; } to { background-color: inherit; } }\r\n    @keyframes destello-fiel-Z { 10% { text-shadow: 0 0 10px gold; } 50% { text-shadow: 0 0 10px rgb(85, 0, 255); } 100% { text-shadow: 0 0 10px rgb(211, 9, 9); } }\r\n    .juego-fiel-text-Z-container .destello { animation: destello-fiel-Z 1s infinite alternate; }\r\n    .juego-fiel-text-Z-container .modal { display: none; position: fixed; z-index: 10000; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 600px; background-color: rgba(0, 0, 0, 0.5); border-radius: 10px; }\r\n    .juego-fiel-text-Z-container .modal-content { background-color: #fefefe; margin: 20px auto; padding: 20px; border: 1px solid #888; border-radius: 10px; text-align: center;\r\n    }\r\n    .juego-fiel-text-Z-container .close { color: #aaa; float: right; font-size: 28px; font-weight: bold; }\r\n    .juego-fiel-text-N-container .close:hover, .juego-fiel-text-Z-container .close:focus { color: black; text-decoration: none; cursor: pointer; }\r\n    .juego-fiel-text-Z-container .titulo-division { color: #dc3545; }\r\n    .juego-fiel-text-Z-container .userAnswer {\r\n     width: 65px;\r\n            padding: 2px 5px;\r\n            height: 30px;\r\n            text-align: center;\r\n            border: 2px solid #cccccc !important;\r\n            border-radius: 5px;\r\n            background-color: #ffffff !important;\r\n            font-size: 18px;\r\n            color: #333;\r\n            display: block;\r\n            margin: 5px auto;\r\n}\r\n\r\n.juego-fiel-text-Z-container .userAnswer:focus {\r\n     border-color: #dc3545 !important;\r\n            outline: none;\r\n            box-shadow: 0 0 5px rgba(220, 53, 69, 0.6);\r\n}\r\n\/* Barra de progreso *\/\r\n.progress-wrapper-Z { \r\n    background-color: #eee; border-radius: 10px; height: 20px; \r\n    width: 100%; margin: 15px 0; position: relative; \r\n    border: 1px solid #ccc; overflow: hidden; \r\n}\r\n#progressBar-fiel-Z { \r\n    background: #4caf50; height: 100%; width: 0%; transition: width 0.3s; \r\n}\r\n.progress-text-Z { \r\n    position: absolute; width: 100%; text-align: center; top: 0; \r\n    font-size: 12px; font-weight: bold; color: #000; line-height: 20px; \r\n}\r\n\r\n\/* Ajuste al modal para que no crezca m\u00e1s que la pantalla *\/\r\n.juego-fiel-text-Z-container .modal-content { \r\n    max-height: 85vh; \/* Evita que salga de la pantalla *\/\r\n    display: flex; \r\n    flex-direction: column; \r\n    position: relative; \r\n}\r\n\/* Permite scroll solo en el contenido *\/\r\n#errorContent-fiel-Z { \r\n    overflow-y: auto; \r\n    margin: 15px 0; \r\n    padding-right: 10px; \r\n}\r\n\/* Fija la X de cerrar arriba a la derecha *\/\r\n.juego-fiel-text-Z-container .close { \r\n    position: absolute; top: 5px; right: 15px; \r\n}\r\n<\/style>\r\n\r\n<!-- ESTRUCTURA HTML -->\r\n<div class=\"juego-fiel-text-Z-container\">\r\n    <div class=\"container\">\r\n       <p class=\"lesson titulo-division\">\"En los n\u00fameros enteros (Z), si quitas m\u00e1s de lo que tienes, el resultado es negativo. \u00a1Es como quedar a deber! Por ejemplo: $3 - 5 = -2$.\"<\/p>\r\n        <div class=\"questions-container\" id=\"exercise-fiel-Z\"><\/div>\r\n        <div id=\"roundResult-fiel-Z\" class=\"hidden\"><\/div>\r\n        <div class=\"progress-wrapper-Z\">\r\n    <div id=\"progressBar-fiel-Z\"><\/div>\r\n    <div class=\"progress-text-Z\" id=\"progressText-fiel-Z\">Racha: 0 \/ 27<\/div>\r\n<\/div>\r\n        <div id=\"consecutiveCorrect-fiel-Z\" class=\"hidden\"><\/div>\r\n        <button id=\"verify-btn-fiel-Z\">Verificar respuestas<\/button>\r\n        <button id=\"continue-btn-fiel-Z\">Continuar reto<\/button>\r\n        <button id=\"finish-btn-fiel-Z\">An\u00e1lisis de errores<\/button>\r\n        <button id=\"restart-btn-fiel-Z\">Reiniciar reto<\/button>\r\n        <div id=\"finishMessage-fiel-Z\" class=\"hidden\"><\/div>\r\n\r\n        <div id=\"errorModal-fiel-Z\" class=\"modal\">\r\n            <div class=\"modal-content\">\r\n                <span id=\"closeError-fiel-Z\" class=\"close\">&times;<\/span>\r\n                <div id=\"errorContent-fiel-Z\"><\/div>\r\n                <button id=\"download-txt-btn-fiel-Z\">Descargar ejercicios a partir de los errores, en PDF<\/button>\r\n            <\/div>\r\n        <\/div>\r\n        <div id=\"winModal-fiel-Z\" class=\"modal\">\r\n            <div class=\"modal-content\">\r\n                <span id=\"closeWin-fiel-Z\" class=\"close\">&times;<\/span>\r\n                <div id=\"winContent-fiel-Z\"><\/div>\r\n            <\/div>\r\n        <\/div>\r\n    <\/div>\r\n\r\n   <audio id=\"audio-9-fiel-Z\" src=\"https:\/\/entrenacalculo.com\/wp-content\/uploads\/2026\/03\/ronda_9.mp3.mp3\" preload=\"auto\"><\/audio>\r\n<audio id=\"audio-18-fiel-Z\" src=\"https:\/\/entrenacalculo.com\/wp-content\/uploads\/2026\/03\/ronda_18.mp3.mp3\" preload=\"auto\"><\/audio>\r\n<audio id=\"audio-victoria-fiel-Z\" src=\"https:\/\/entrenacalculo.com\/wp-content\/uploads\/2026\/03\/victoria_27.mp3.mp3\" preload=\"auto\"><\/audio>\r\n<audio id=\"audio-reintento-leve-fiel-Z\" src=\"https:\/\/entrenacalculo.com\/wp-content\/uploads\/2026\/03\/error_leve.mp3.mp3\" preload=\"auto\"><\/audio>\r\n<audio id=\"audio-reintento-grave-fiel-Z\" src=\"https:\/\/entrenacalculo.com\/wp-content\/uploads\/2026\/03\/error_grave.mp3.mp3\" preload=\"auto\"><\/audio>\r\n<\/div>\r\n\r\n<!-- C\u00d3DIGO JAVASCRIPT -->\r\n<script>\r\n(function() {\r\n    const suffix = '-fiel-Z';\r\n    const consecutiveCorrectKey = 'consecutiveCorrect_fiel_Z';\r\n    const allErrorsKey = 'allErrors_fiel_Z';\r\n    const exercisesKey = 'exercises_fiel_Z';\r\n\r\n    const exerciseDiv = document.getElementById('exercise' + suffix);\r\n    const roundResult = document.getElementById('roundResult' + suffix);\r\n    const consecutiveCorrectPara = document.getElementById('consecutiveCorrect' + suffix);\r\n    const errorModal = document.getElementById('errorModal' + suffix);\r\n    const winModal = document.getElementById('winModal' + suffix);\r\n    const errorContent = document.getElementById('errorContent' + suffix);\r\n    const winContent = document.getElementById('winContent' + suffix);\r\n    \/\/const successAudio = document.getElementById('success-audio' + suffix);\r\n    \/\/const errorAudio = document.getElementById('error-audio' + suffix);\r\n\r\n    let consecutiveCorrect = parseInt(localStorage.getItem(consecutiveCorrectKey)) || 0;\r\n    let allErrors = JSON.parse(localStorage.getItem(allErrorsKey)) || [];\r\n    let startTime;\r\n    let verifyButtonClicked = false;\r\n    \r\n    \/\/ --- ACTUALIZACI\u00d3N DE BARRA ---\r\n    function updateProgressBar() {\r\n        const perc = Math.min((consecutiveCorrect \/ 27) * 100, 100);\r\n        document.getElementById('progressBar-fiel-Z').style.width = perc + '%';\r\n        document.getElementById('progressText-fiel-Z').innerHTML = `Racha: ${consecutiveCorrect} \/ 27`;\r\n    }\r\n\r\n    function generateExercise() {\r\n        \/\/ Generamos dos n\ufffdmeros del 1 al 18 sin restricciones de orden\r\n        const n1 = Math.floor(Math.random() * 18) + 1; \r\n    const n2 = Math.floor(Math.random() * 18) + 1;\r\n    \r\n    \/\/ El resultado ahora puede ser negativo (Ej: 5 - 12 = -7)\r\n    return { factor: n1, num: n2, correctAnswer: n1 - n2 };\r\n    }\r\n\r\n    function generateExercises() {\r\n        const exercises = [];\r\n        let previousExercises = JSON.parse(localStorage.getItem(exercisesKey));\r\n        let newExercises;\r\n        do {\r\n            exercises.length = 0;\r\n            while (exercises.length < 9) {\r\n                const exercise = generateExercise();\r\n                const isUnique = !exercises.some(e => e.factor === exercise.factor && e.num === exercise.num);\r\n                if (isUnique) exercises.push(exercise);\r\n            }\r\n            newExercises = JSON.stringify(exercises);\r\n        } while (previousExercises && newExercises === previousExercises);\r\n        localStorage.setItem(exercisesKey, newExercises);\r\n        return exercises;\r\n    }\r\n\r\n    function showExercises(exercises) {\r\n        if (!exerciseDiv) return;\r\n        exerciseDiv.innerHTML = '';\r\n        exercises.forEach((exercise, index) => {\r\n            \/\/ -- CORRECCI\u00d3N APLICADA AQU\u00cd --\r\n            exerciseDiv.innerHTML += `\r\n            <div class=\"question\">\r\n                <p>Pregunta ${index + 1}: \u00bfCu\u00e1nto es ${exercise.factor} - ${exercise.num}?<\/p>\r\n                <input type=\"text\" inputmode=\"numeric\" pattern=\"-?[0-9]*\" id=\"userAnswer${index}${suffix}\" class=\"userAnswer\">\r\n                <p id=\"feedback${index}${suffix}\" class=\"feedback\"><\/p>\r\n            <\/div>`;\r\n        });\r\n        updateProgressBar(); \/\/ --- AGREGAR ESTO: Actualiza la barra al mostrar ejercicios ---\r\n    }\r\n\r\n    function verifyAnswers() {\r\n        if (verifyButtonClicked) return;\r\n        verifyButtonClicked = true;\r\n        let correctAnswers = 0;\r\n        const exercises = JSON.parse(localStorage.getItem(exercisesKey));\r\n        const errors = [];\r\n        if (!exercises) return;\r\n        exercises.forEach((exercise, index) => {\r\n            const userAnswer = parseInt(document.getElementById(`userAnswer${index}${suffix}`).value);\r\n            const feedbackPara = document.getElementById(`feedback${index}${suffix}`);\r\n            if (!isNaN(userAnswer) && userAnswer === exercise.correctAnswer) {\r\n                feedbackPara.innerHTML = '\u00a1Correcto!';\r\n                feedbackPara.classList.add('correct-answer');\r\n                correctAnswers++;\r\n                consecutiveCorrect++;\r\n               \/\/ playSuccessSound();\r\n            } else {\r\n                feedbackPara.innerHTML = `\u00a1Lo correcto es ${exercise.correctAnswer}!`;\r\n                feedbackPara.classList.add('incorrect-answer');\r\n                feedbackPara.classList.add('error-blink');\r\n                consecutiveCorrect = 0;\r\n                errors.push(exercise);\r\n               \/\/ playErrorSound();\r\n            }\r\n        });\r\n        \/\/ --- INICIO DE L\u00d3GICA DE AUDIOS POR PRIORIDAD Y RACHA ---\r\n        let huboFallo = errors.length > 0;\r\n\r\n        if (consecutiveCorrect >= 27) {\r\n            \/\/ PRIORIDAD 1: VICTORIA FINAL\r\n            playAudio('audio-victoria' + suffix);\r\n        } \r\n        else if (huboFallo) {\r\n            \/\/ PRIORIDAD 2: ERRORES (REINTENTOS)\r\n            let totalErrores = errors.length;\r\n            if (totalErrores <= 2) {\r\n                playAudio('audio-reintento-leve' + suffix);\r\n            } else {\r\n                playAudio('audio-reintento-grave' + suffix);\r\n            }\r\n        } \r\n        else {\r\n            \/\/ PRIORIDAD 3: RONDAS PERFECTAS (9 o 18)\r\n            if (consecutiveCorrect === 9) {\r\n                playAudio('audio-9' + suffix);\r\n            } \r\n            else if (consecutiveCorrect === 18) {\r\n                playAudio('audio-18' + suffix);\r\n            }\r\n        }\r\n        \/\/ --- FIN DE L\u00d3GICA DE AUDIOS ---\r\n        localStorage.setItem(consecutiveCorrectKey, consecutiveCorrect);\r\n        allErrors.push(...errors);\r\n        localStorage.setItem(allErrorsKey, JSON.stringify(allErrors));\r\n        updateProgressBar(); \/\/ --- AGREGAR ESTO: La barra se mueve justo despu\u00e9s de verificar ---\r\n        showRoundResult(correctAnswers);\r\n        showConsecutiveCorrect();\r\n    }\r\n\r\n    function showRoundResult(correctAnswers) {\r\n        if(roundResult) {\r\n            roundResult.innerHTML = `Lograste ${correctAnswers} respuestas correctas de 9, en esta ronda.`;\r\n            roundResult.style.color = 'blue';\r\n            roundResult.classList.remove('hidden');\r\n        }\r\n    }\r\n\r\n    function showConsecutiveCorrect() {\r\n        if(consecutiveCorrectPara) {\r\n            consecutiveCorrectPara.innerHTML = `Has alcanzado ${consecutiveCorrect} respuestas correctas seguidas.`;\r\n            consecutiveCorrectPara.style.color = 'green';\r\n            consecutiveCorrectPara.classList.remove('hidden');\r\n            if (consecutiveCorrect >= 27) {\r\n                const finishTime = new Date() - startTime;\r\n                const minutes = Math.floor((finishTime % (1000 * 60 * 60)) \/ (1000 * 60));\r\n                const seconds = Math.floor((finishTime % (1000 * 60)) \/ 1000);\r\n                const totalErrors = allErrors.length;\r\n                const totalTimeForPoints = Math.floor(finishTime \/ 1000);\r\n                const totalPoints = calculatePoints(consecutiveCorrect, totalTimeForPoints, totalErrors);\r\n                \r\n                winContent.innerHTML = `<h2 style=\"color: blue;\" class=\"destello\">\u00a1Ganaste el juego!<br>de la resta<\/h2> <span style=\"font-size: 56px;\" class=\"destello\">&#x1F3C6;<\/span>`;\r\n                winContent.innerHTML += `<p><b>\u00a1Felicidades!<\/b> Has logrado <b> 27 respuestas correctas consecutivas.<\/b><\/p>`;\r\n                winContent.innerHTML += `<p>Tiempo de finalizaci\u00f3n: <b>${minutes} minutos ${seconds} segundos<\/b><\/p>`;\r\n                winContent.innerHTML += `<p>Puntaje total: <b>${totalPoints} Puntos<\/b><\/p>`;\r\n                winContent.style.color = 'blue';\r\n                if(winModal) winModal.style.display = \"block\";\r\n                \r\n                \/\/localStorage.removeItem(consecutiveCorrectKey);\r\n                \/\/localStorage.removeItem(allErrorsKey);\r\n                \/\/localStorage.removeItem(exercisesKey);\r\n            } else {\r\n                consecutiveCorrectPara.innerHTML += ` \u00a1Necesitas llegar a 27 para ganar!`;\r\n            }\r\n        }\r\n    }\r\n\r\n    function calculatePoints(finalConsecutive, totalTimeSeconds, totalErrors) {\r\n        const basePoints = finalConsecutive * 10;\r\n        const errorPenalty = totalErrors * 5;\r\n        const timePenalty = totalTimeSeconds * 0.5;\r\n        let streakBonus = 0;\r\n        if (finalConsecutive >= 27) { streakBonus += 300; } \r\n        else if (finalConsecutive >= 18) { streakBonus += 150; } \r\n        else if (finalConsecutive >= 9) { streakBonus += 50; }\r\n        const totalPoints = basePoints - errorPenalty - timePenalty + streakBonus;\r\n        return Math.max(0, Math.floor(totalPoints));\r\n    }\r\n\r\n    function showErrors() {\r\n        const currentAllErrors = JSON.parse(localStorage.getItem(allErrorsKey)) || [];\r\n        if(errorContent) {\r\n            errorContent.innerHTML = '<h2>Errores en el juego. <br> Pero corregidos.<\/h2>';\r\n            if (currentAllErrors.length > 0) {\r\n                 currentAllErrors.forEach((error, index) => {\r\n                    errorContent.innerHTML += `<p>${index + 1}. <span style=\"color: red;\">${error.factor} - ${error.num} = ${error.correctAnswer}<\/span><\/p>`;\r\n                });\r\n            } else {\r\n                errorContent.innerHTML += '<p>\u00a1No has cometido errores!<\/p>';\r\n            }\r\n        }\r\n        if(errorModal) errorModal.style.display = \"block\";\r\n    }\r\n\r\n    function refreshGame() {\r\n        verifyButtonClicked = false;\r\n        if (roundResult) roundResult.classList.add('hidden');\r\n        const exercises = generateExercises();\r\n        showExercises(exercises);\r\n    }\r\n\r\n    function restartGame() {\r\n        startTime = new Date(); \r\n        consecutiveCorrect = 0; \r\n        allErrors = [];\r\n        \r\n        \/\/ --- ESTAS SON LAS L\u00cdNEAS QUIR\u00daRGICAS A AGREGAR ---\r\n    localStorage.setItem(consecutiveCorrectKey, '0');\r\n    localStorage.setItem(allErrorsKey, JSON.stringify([])); \/\/ Limpia el historial para el nuevo juego\r\n    localStorage.removeItem(exercisesKey); \/\/ Obliga a generar ejercicios nuevos\r\n    \/\/ --------------------------------------------------\r\n \r\n        if (roundResult) roundResult.classList.add('hidden');\r\n        if (consecutiveCorrectPara) consecutiveCorrectPara.classList.add('hidden');\r\n        verifyButtonClicked = false; \r\n        updateProgressBar(); \/\/ --- AGREGAR ESTO: La barra vuelve a cero visualmente ---\r\n        refreshGame(); \r\n    }\r\n            \r\n    \/*function playSuccessSound() { if(successAudio) successAudio.play().catch(e => {}); }*\/\r\n   \/* function playErrorSound() { if(errorAudio) errorAudio.play().catch(e => {}); }*\/\r\n\r\n    function closeErrorModal() { if(errorModal) errorModal.style.display = \"none\"; }\r\n    function closeWinModal() { if(winModal) winModal.style.display = \"none\"; }\r\n\r\n  function generateTextFile() {\r\n    const allErrors = JSON.parse(localStorage.getItem(allErrorsKey)) || [];\r\n    let content = \"Lecci\u00f3n Instructiva: El Arte de Restar\\n\\n\";\r\n    \r\n    if (allErrors.length > 0) {\r\n  const firstError = allErrors[0];\r\n    content += \"\u00a1Hola! Has tenido un peque\u00f1o tropiezo con los N\u00fameros Enteros (Z). No te preocupes, manejar n\u00fameros negativos es como manejar deudas o pisos bajo tierra.\\n\\n\";\r\n    content += \"**Concepto Clave:**\\n\\n\";\r\n    content += `En la operaci\u00f3n ${firstError.factor} - ${firstError.num}, si el segundo n\u00famero es mayor, el resultado ser\u00e1 un n\u00famero negativo.\\n\\n`;\r\n    content += \"**Regla de Oro:**\\n\";\r\n    content += \"1. Si tienes 5 y quitas 8, te quedas con 'deuda' de 3. Resultado: -3.\\n\";\r\n    content += \"2. En la recta num\u00e9rica, te mueves hacia la izquierda.\\n\\n\";\r\n    content += \"Ejercicios para dominar los negativos:\\n\\n\";\r\n    } else {\r\n        content += \"\u00a1Felicidades! Eres un experto en restas. No has cometido errores en este reto.\\n\\n\";\r\n    }\r\n    \r\n    allErrors.forEach((error, index) => {\r\n        content += `${index + 1}. Calcula la diferencia: ${error.factor} - ${error.num} = \\n`;\r\n    });\r\n\r\n    \/\/ ... (aqu\u00ed sigue tu c\u00f3digo de jsPDF)\r\n\/\/ --- ESTA ES LA PARTE QUE CAMBIA PARA GENERAR PDF ---\r\n    const { jsPDF } = window.jspdf;\r\n    const doc = new jsPDF();\r\n    \r\n    \/\/ Configuramos fuente y tama\u00f1o\r\n    doc.setFont(\"helvetica\", \"normal\");\r\n    doc.setFontSize(11);\r\n\r\n    \/\/ Dividimos tu variable 'content' en l\u00edneas que quepan en el ancho del PDF\r\n    const splitText = doc.splitTextToSize(content, 180); \r\n    \r\n    \/\/ Escribimos el texto en el PDF\r\n    let yAxis = 20;\r\n    splitText.forEach(line => {\r\n        if (yAxis > 275) { \/\/ Si llegamos al final de la p\u00e1gina, creamos otra\r\n            doc.addPage();\r\n            yAxis = 20;\r\n        }\r\n        doc.text(line, 15, yAxis);\r\n        yAxis += 7; \/\/ Espaciado entre l\u00edneas\r\n    });\r\n    \r\n\/\/ --- NUEVA MEJORA: GR\u00c1FICO DE RENDIMIENTO ---\r\n    if (allErrors.length > 0) {\r\n        \/\/ Verificamos espacio en la p\u00e1gina\r\n        if (yAxis > 230) { doc.addPage(); yAxis = 20; }\r\n        \r\n        yAxis += 15; \r\n        doc.setFont(\"helvetica\", \"bold\");\r\n        doc.text(\"AN\u00c1LISIS DE RENDIMIENTO (Frecuencia de errores)\", 15, yAxis);\r\n        yAxis += 10;\r\n        doc.setFont(\"helvetica\", \"normal\");\r\n\r\n        \/\/ L\u00f3gica de conteo de errores\r\n        const conteo = {};\r\n        allErrors.forEach(err => {\r\n            const etiqueta = `${err.factor} - ${err.num}`;\r\n            conteo[etiqueta] = (conteo[etiqueta] || 0) + 1;\r\n        });\r\n\r\n        \/\/ Dibujo de las barras amarillas\r\n        Object.entries(conteo).forEach(([operacion, cantidad]) => {\r\n            doc.text(operacion, 15, yAxis + 5);\r\n            doc.setFillColor(220, 53, 69); \/\/ Color amarillo multiplicaci\u00f3n\r\n            doc.rect(40, yAxis, cantidad * 15, 6, 'F'); \r\n            doc.text(`${cantidad} fallo(s)`, 45 + (cantidad * 15), yAxis + 5);\r\n            yAxis += 10;\r\n            if (yAxis > 275) { doc.addPage(); yAxis = 20; }\r\n        });\r\n    }\r\n    \/\/ Descargamos el archivo con formato PDF\r\n    doc.save('Tarea_Entrenamiento_Resta.pdf');\r\n    \/\/ --- FIN DEL CAMBIO ---\r\n}\r\n\r\n    \/\/ Event Listeners\r\n    document.getElementById('restart-btn' + suffix)?.addEventListener('click', restartGame);\r\n    document.getElementById('verify-btn' + suffix)?.addEventListener('click', verifyAnswers);\r\n    document.getElementById('continue-btn' + suffix)?.addEventListener('click', refreshGame);\r\n    document.getElementById('finish-btn' + suffix)?.addEventListener('click', showErrors);\r\n    document.getElementById('download-txt-btn' + suffix)?.addEventListener('click', generateTextFile);\r\n    document.getElementById('closeError' + suffix)?.addEventListener('click', closeErrorModal);\r\n    document.getElementById('closeWin' + suffix)?.addEventListener('click', closeWinModal);\r\n\r\n    \/\/ Inicializaci\u00f3n\r\n    const initialExercises = JSON.parse(localStorage.getItem(exercisesKey)) || generateExercises();\r\n    showExercises(initialExercises);\r\n    startTime = new Date();\r\n})();\r\nfunction playAudio(id) {\r\n    const audio = document.getElementById(id);\r\n   if (audio) {\r\n        audio.pause();       \/\/ Detiene cualquier sonido anterior inmediatamente\r\n        audio.load();        \/\/ Fuerza la recarga para eliminar el lag\/retraso\r\n        audio.currentTime = 0; \r\n        audio.volume = 0.6;    \r\n        audio.play().catch(e => console.log(\"Audio esperando interacci\u00f3n del usuario\"));\r\n    }\r\n}\r\n<\/script>\r\n\r\n\r\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>\u00abEn los n\u00fameros enteros (Z), si quitas m\u00e1s de lo que tienes, el resultado es negativo. \u00a1Es como quedar a deber! Por ejemplo: $3 &#8211; 5 = -2$.\u00bb Racha: 0 \/ 27 Verificar respuestas Continuar reto An\u00e1lisis de errores Reiniciar reto &times; Descargar ejercicios a partir de los errores, en PDF &times;<\/p>","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1272","page","type-page","status-publish","hentry"],"blocksy_meta":[],"_hostinger_reach_plugin_has_subscription_block":false,"_hostinger_reach_plugin_is_elementor":false,"_links":{"self":[{"href":"https:\/\/entrenacalculo.com\/en\/wp-json\/wp\/v2\/pages\/1272","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/entrenacalculo.com\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/entrenacalculo.com\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/entrenacalculo.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/entrenacalculo.com\/en\/wp-json\/wp\/v2\/comments?post=1272"}],"version-history":[{"count":18,"href":"https:\/\/entrenacalculo.com\/en\/wp-json\/wp\/v2\/pages\/1272\/revisions"}],"predecessor-version":[{"id":1464,"href":"https:\/\/entrenacalculo.com\/en\/wp-json\/wp\/v2\/pages\/1272\/revisions\/1464"}],"wp:attachment":[{"href":"https:\/\/entrenacalculo.com\/en\/wp-json\/wp\/v2\/media?parent=1272"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}