Skip to content

Instantly share code, notes, and snippets.

@diegovgsilva95
Created December 10, 2024 07:06
Show Gist options
  • Select an option

  • Save diegovgsilva95/434ece8a2c95dc083d96032f7fd462f2 to your computer and use it in GitHub Desktop.

Select an option

Save diegovgsilva95/434ece8a2c95dc083d96032f7fd462f2 to your computer and use it in GitHub Desktop.
JS - Math and Linguistics experimentation: calculating cyclic pattern from Gematria-like reduction from each English word for decimal digits
import {log} from "console"
const range = (n,x)=>Array.from(Array(Math.max(0,x-n+1))).map((_,i)=>i+n)
const numerals = "zero|one|two|three|four|five|six|seven|eight|nine".split("|")
const alpha = " "+String.fromCharCode(...range(96+1, 96+26))
for(let numeral of numerals){
let chain = [numeral]
let cycled = false
do {
let last = chain[chain.length-1]
let poses = [...last].map(l=>alpha.indexOf(l))
let sum = poses.reduce((p,v)=>p+v)
let reduction = sum
while(reduction >= 10)
reduction = (reduction/10|0)+(reduction%10)
let next = numerals[reduction]
cycled = chain.includes(next)
chain.push(next)
} while(!cycled)
log(chain.join(" -> "), "["+chain.map(num => numerals.indexOf(num)).join("")+"...]")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment