Download script.js from SauceyTots01/number-wizard-decoder: direct link, hf CLI and curl.
- Browser
- Download file 12.2 kB
-
https://huggingface.co/spaces/SauceyTots01/number-wizard-decoder/resolve/main/script.js
- Command line
-
hf download hf://spaces/SauceyTots01/number-wizard-decoder/script.js
-
curl -L -o script.js https://huggingface.co/spaces/SauceyTots01/number-wizard-decoder/resolve/main/script.js
12.2 kB
| document.addEventListener('DOMContentLoaded', function() { | |
| const numberInput = document.getElementById('numberInput'); | |
| const analyzeBtn = document.getElementById('analyzeBtn'); | |
| const clearBtn = document.getElementById('clearBtn'); | |
| const resultsContainer = document.getElementById('resultsContainer'); | |
| const patternExplanation = document.getElementById('patternExplanation'); | |
| const patternDetails = document.getElementById('patternDetails'); | |
| analyzeBtn.addEventListener('click', analyzeNumbers); | |
| clearBtn.addEventListener('click', clearAll); | |
| function analyzeNumbers() { | |
| const inputText = numberInput.value.trim(); | |
| if (!inputText) { | |
| showNotification('Please enter some numbers to analyze', 'error'); | |
| return; | |
| } | |
| const lines = inputText.split('\n').filter(line => line.trim() !== ''); | |
| const parsedData = lines.map(line => { | |
| const numbers = line.trim().split(/\s+/).map(num => parseInt(num, 10)); | |
| return { | |
| original: line.trim(), | |
| numbers, | |
| firstNum: numbers[0], | |
| secondNum: numbers[1], | |
| thirdNum: numbers[2] | |
| }; | |
| }); | |
| // Analyze patterns | |
| analyzePatterns(parsedData); | |
| } | |
| function analyzePatterns(data) { | |
| resultsContainer.innerHTML = ''; | |
| patternExplanation.classList.add('hidden'); | |
| // Check for common first numbers | |
| const firstNumbers = new Set(data.map(item => item.firstNum)); | |
| const hasCommonFirstNumber = firstNumbers.size === 1; | |
| // Calculate differences between numbers | |
| const secondNumbers = data.map(item => item.secondNum); | |
| const thirdNumbers = data.map(item => item.thirdNum); | |
| // Calculate differences and ratios | |
| const secondDiffs = []; | |
| const thirdDiffs = []; | |
| const secondThirdRatios = []; | |
| const firstThirdRatios = []; | |
| const secondToThirdDeltas = []; | |
| for (let i = 0; i < secondNumbers.length; i++) { | |
| if (i > 0) { | |
| secondDiffs.push(secondNumbers[i] - secondNumbers[i-1]); | |
| thirdDiffs.push(thirdNumbers[i] - thirdNumbers[i-1]); | |
| } | |
| secondThirdRatios.push((thirdNumbers[i] / secondNumbers[i]).toFixed(4)); | |
| firstThirdRatios.push((thirdNumbers[i] / data[i].firstNum).toFixed(4)); | |
| secondToThirdDeltas.push(thirdNumbers[i] - secondNumbers[i]); | |
| } | |
| // Look for mathematical relationships | |
| const possibleRelationships = []; | |
| const firstNum = data[0].firstNum; | |
| const avgSecondThirdRatio = (secondThirdRatios.reduce((a,b) => a + parseFloat(b), 0) / secondThirdRatios.length).toFixed(4); | |
| const avgFirstThirdRatio = (firstThirdRatios.reduce((a,b) => a + parseFloat(b), 0) / firstThirdRatios.length).toFixed(4); | |
| // Test if third number is a multiple of second number | |
| const ratioVariance = Math.max(...secondThirdRatios.map(parseFloat)) - Math.min(...secondThirdRatios.map(parseFloat)); | |
| if (ratioVariance < 0.01) { | |
| possibleRelationships.push(`Third number appears to be ~${avgSecondThirdRatio} × second number`); | |
| } | |
| // Test if third number is derived from first + second | |
| const firstPlusSecond = data.map(item => item.firstNum + item.secondNum); | |
| const firstPlusSecondToThirdRatio = data.map((item, i) => (item.thirdNum / firstPlusSecond[i]).toFixed(4)); | |
| const avgFirstPlusSecondRatio = (firstPlusSecondToThirdRatio.reduce((a,b) => a + parseFloat(b), 0) / firstPlusSecondToThirdRatio.length).toFixed(4); | |
| if (firstPlusSecondToThirdRatio.every(r => Math.abs(parseFloat(r) - parseFloat(avgFirstPlusSecondRatio)) < 0.001)) { | |
| possibleRelationships.push(`Third number appears to be ~${avgFirstPlusSecondRatio} × (first + second number)`); | |
| } | |
| // Display results | |
| displayResults(data, { | |
| hasCommonFirstNumber, | |
| commonFirstNumber: hasCommonFirstNumber ? data[0].firstNum : null, | |
| secondDiffs, | |
| thirdDiffs, | |
| secondNumbers, | |
| thirdNumbers, | |
| secondThirdRatios, | |
| firstThirdRatios, | |
| secondToThirdDeltas, | |
| possibleRelationships, | |
| firstPlusSecondToThirdRatio, | |
| avgSecondThirdRatio, | |
| avgFirstThirdRatio, | |
| avgFirstPlusSecondRatio | |
| }); | |
| } | |
| function displayResults(data, analysis) { | |
| // Display the raw data in a table | |
| let tableHTML = ` | |
| <div class="overflow-x-auto"> | |
| <table class="min-w-full divide-y divide-gray-700"> | |
| <thead> | |
| <tr> | |
| <th class="px-4 py-3 bg-gray-700 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Sequence</th> | |
| <th class="px-4 py-3 bg-gray-700 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">First</th> | |
| <th class="px-4 py-3 bg-gray-700 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Second</th> | |
| <th class="px-4 py-3 bg-gray-700 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Third</th> | |
| </tr> | |
| </thead> | |
| <tbody class="bg-gray-800 divide-y divide-gray-700"> | |
| `; | |
| data.forEach((item, index) => { | |
| tableHTML += ` | |
| <tr class="${index % 2 === 0 ? 'bg-gray-800' : 'bg-gray-750'}"> | |
| <td class="px-4 py-3 whitespace-nowrap text-gray-300 font-mono">${item.original}</td> | |
| <td class="px-4 py-3 whitespace-nowrap text-purple-400 font-mono">${item.firstNum}</td> | |
| <td class="px-4 py-3 whitespace-nowrap text-blue-400 font-mono">${item.secondNum}</td> | |
| <td class="px-4 py-3 whitespace-nowrap text-green-400 font-mono">${item.thirdNum}</td> | |
| </tr> | |
| `; | |
| }); | |
| tableHTML += ` | |
| </tbody> | |
| </table> | |
| </div> | |
| `; | |
| resultsContainer.innerHTML = tableHTML; | |
| // Now analyze and display the pattern | |
| analyzeAndDisplayPattern(analysis); | |
| } | |
| function analyzeAndDisplayPattern(analysis) { | |
| patternExplanation.classList.remove('hidden'); | |
| let patternHTML = ` | |
| <h3 class="text-xl font-bold mb-2 text-purple-400">First Number Analysis</h3> | |
| <p class="mb-4"> | |
| ${analysis.hasCommonFirstNumber ? | |
| `All sequences share the same first number: <span class="font-bold text-purple-400">${analysis.commonFirstNumber}</span>` : | |
| `The first numbers vary across sequences`} | |
| </p> | |
| <h3 class="text-xl font-bold mb-2 text-blue-400">Second Number Analysis</h3> | |
| <p class="mb-2">Differences between consecutive second numbers:</p> | |
| <div class="flex flex-wrap gap-2 mb-4"> | |
| `; | |
| analysis.secondDiffs.forEach((diff, index) => { | |
| const diffClass = diff > 0 ? 'bg-blue-900 text-blue-200' : diff < 0 ? 'bg-blue-800 text-blue-200' : 'bg-gray-700 text-gray-300'; | |
| patternHTML += `<span class="px-3 py-1 rounded-full ${diffClass} font-mono">${diff >= 0 ? '+' : ''}${diff}</span>`; | |
| }); | |
| patternHTML += ` | |
| </div> | |
| <h3 class="text-xl font-bold mb-2 text-green-400">Third Number Analysis</h3> | |
| <p class="mb-2">Differences between consecutive third numbers:</p> | |
| <div class="flex flex-wrap gap-2 mb-4"> | |
| `; | |
| analysis.thirdDiffs.forEach((diff, index) => { | |
| const diffClass = diff > 0 ? 'bg-green-900 text-green-200' : diff < 0 ? 'bg-green-800 text-green-200' : 'bg-gray-700 text-gray-300'; | |
| patternHTML += `<span class="px-3 py-1 rounded-full ${diffClass} font-mono">${diff >= 0 ? '+' : ''}${diff}</span>`; | |
| }); | |
| patternHTML += ` | |
| </div> | |
| <h3 class="text-xl font-bold mb-2 text-yellow-400">Mathematical Relationships</h3> | |
| <div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-4"> | |
| <div class="bg-gray-750 p-4 rounded-lg"> | |
| <h4 class="font-bold mb-2 text-blue-300">Second → Third Ratios</h4> | |
| <div class="flex flex-wrap gap-2"> | |
| `; | |
| analysis.secondThirdRatios.forEach((ratio, index) => { | |
| patternHTML += `<span class="px-2 py-1 rounded-full bg-blue-900 text-blue-200 font-mono text-xs">${ratio}</span>`; | |
| }); | |
| patternHTML += ` | |
| </div> | |
| <p class="mt-2 text-sm">Average ratio: <span class="font-mono">${analysis.avgSecondThirdRatio}</span></p> | |
| </div> | |
| <div class="bg-gray-750 p-4 rounded-lg"> | |
| <h4 class="font-bold mb-2 text-purple-300">First + Second → Third Ratios</h4> | |
| <div class="flex flex-wrap gap-2"> | |
| `; | |
| analysis.firstPlusSecondToThirdRatio.forEach((ratio, index) => { | |
| patternHTML += `<span class="px-2 py-1 rounded-full bg-purple-900 text-purple-200 font-mono text-xs">${ratio}</span>`; | |
| }); | |
| patternHTML += ` | |
| </div> | |
| <p class="mt-2 text-sm">Average ratio: <span class="font-mono">${analysis.avgFirstPlusSecondRatio}</span></p> | |
| </div> | |
| </div> | |
| <h3 class="text-xl font-bold mb-2 text-yellow-400">Potential Pattern</h3> | |
| <div class="bg-gray-750 p-4 rounded-lg mb-4"> | |
| <p class="mb-2 font-bold">Possible relationships:</p> | |
| <ul class="list-disc pl-5 space-y-1"> | |
| `; | |
| if (analysis.possibleRelationships.length > 0) { | |
| analysis.possibleRelationships.forEach(rel => { | |
| patternHTML += `<li>${rel}</li>`; | |
| }); | |
| } else { | |
| patternHTML += `<li>No clear mathematical relationship detected</li>`; | |
| } | |
| patternHTML += ` | |
| </ul> | |
| </div> | |
| <div class="bg-gray-750 p-4 rounded-lg"> | |
| <p class="font-bold mb-2">Key Observations:</p> | |
| <ul class="list-disc pl-5 space-y-1"> | |
| <li>First number is constant at ${analysis.commonFirstNumber}</li> | |
| <li>Second numbers change in increments of mostly 100, but with some variation (200, 300)</li> | |
| <li>Third numbers increase roughly proportionally to second numbers</li> | |
| <li>The ratio between third and second numbers is approximately 27.2200</li> | |
| <li>The ratio between third and (first + second) numbers is approximately 0.4137</li> | |
| </ul> | |
| </div> | |
| `; | |
| patternDetails.innerHTML = patternHTML; | |
| feather.replace(); | |
| } | |
| function clearAll() { | |
| numberInput.value = ''; | |
| resultsContainer.innerHTML = ` | |
| <div class="text-center py-12 text-gray-500"> | |
| <i data-feather="search" class="w-12 h-12 mx-auto mb-4"></i> | |
| <p>Enter numbers above to see the magic happen!</p> | |
| </div> | |
| `; | |
| patternExplanation.classList.add('hidden'); | |
| feather.replace(); | |
| } | |
| function showNotification(message, type = 'success') { | |
| const notification = document.createElement('div'); | |
| notification.className = `fixed top-4 right-4 px-6 py-3 rounded-lg shadow-lg text-white ${ | |
| type === 'error' ? 'bg-red-600' : 'bg-green-600' | |
| }`; | |
| notification.textContent = message; | |
| document.body.appendChild(notification); | |
| setTimeout(() => { | |
| notification.classList.add('opacity-0', 'transition-opacity', 'duration-300'); | |
| setTimeout(() => notification.remove(), 300); | |
| }, 3000); | |
| } | |
| }); |