pull down to refresh

LOKI + IDUN + ODIN = THOR 1543 + 3082 + 5032 = 9657 1583 + 3042 + 5032 = 9657 2174 + 4693 + 1643 = 8510 2194 + 4673 + 1643 = 8510 3104 + 4567 + 1547 = 9218 3164 + 4507 + 1547 = 9218
(Terrible) source code
const start = Date.now(); const solutions = []; // no leading 0's, start at 1 for (let L = 1; L < 10; L++) { // no leading 0's, start at 1 for (let O = 1; O < 10; O++) { for (let K = 0; K < 10; K++) { // no leading 0's, start at 1 for (let I = 1; I < 10; I++) { for (let D = 0; D < 10; D++) { for (let U = 0; U < 10; U++) { for (let N = 0; N < 10; N++) { // no leading 0's, start at 1 for (let T = 1; T < 10; T++) { for (let H = 0; H < 10; H++) { for (let R = 0; R < 10; R++) { const potentialSolution = { L, O, K, I, D, U, N, T, H, R }; const loki = Number(`${L}${O}${K}${I}`); const idun = Number(`${I}${D}${U}${N}`); const odin = Number(`${O}${D}${I}${N}`); const thor = Number(`${T}${H}${O}${R}`); const uniqueNumbersUsed = new Set( Object.values(potentialSolution) ); if ( Object.values(potentialSolution).length === uniqueNumbersUsed.size ) { if (loki + idun + odin === thor) { console.log( `Found solution after ${Date.now() - start}ms`, potentialSolution ); solutions.push(potentialSolution); } } } } } } } } } } } } console.log({ solutions }); console.log(`Duration: ${Date.now() - start}ms`);