File size: 12,181 Bytes
5cdcc93 5258a42 5cdcc93 5258a42 5cdcc93 5258a42 5cdcc93 5258a42 5cdcc93 5258a42 5cdcc93 5258a42 5cdcc93 5258a42 5cdcc93 5258a42 5cdcc93 5258a42 5cdcc93 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | 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);
}
}); |