Skip to content

Instantly share code, notes, and snippets.

@KrishnaPravin
Last active October 13, 2023 06:46
Show Gist options
  • Save KrishnaPravin/bb02a18bcc07738bf6dd08c4b0fec161 to your computer and use it in GitHub Desktop.
Save KrishnaPravin/bb02a18bcc07738bf6dd08c4b0fec161 to your computer and use it in GitHub Desktop.
RTO-Number.js
const letters = {
'A': 1,
'T': 4,
'M': 4,
'N': 5,
}
// tn = 9, 42 = 6, am = 5
// tn42am = 2
const ns0 = [1,3,5,6,9,10,14,15,16,18,21,24,27,32,33,36,42,46,50,51]
const ns1 = [19,23,37,41,45]
const ns2 = [20,52,55]
function reduce(numStr) {
const n = numStr.split('').reduce((acc,c) => acc += Number(letters[c] || c), 0)
return n < 58 ? n : reduce(n.toString())
}
let n = 3900, k = [], j = [], l = [];
while(n <= 4900) {
const str = 'TN42AM' + n
const r = reduce(str)
ns1.includes(r) && k.push([str, r, 'ns1'].join('-'));
ns0.includes(r) && j.push([str, r, 'ns0'].join('-'));
ns2.includes(r) && l.push([str, r, 'ns2'].join('-'));
n++;
}
console.log(k, j, l)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment