Skip to content

Instantly share code, notes, and snippets.

@peko
Last active September 7, 2015 10:49
Show Gist options
  • Save peko/0fac6ca9c5b5b0c27181 to your computer and use it in GitHub Desktop.
Save peko/0fac6ca9c5b5b0c27181 to your computer and use it in GitHub Desktop.
variants = {}
for i in [1000..9999]
c = "#{i}"
sum = parseInt(c[0]) + parseInt(c[1]) + parseInt(c[2]) + parseInt(c[3])
if c.search(0)<0 and sum is 10
n = c.split('').sort().join('')
variants[n]?=0
variants[n]++
c = 0
for v, i of variants
c++
console.log c, v, i
# 1 '1117' 4
# 2 '1126' 12
# 3 '1135' 12
# 4 '1144' 6
# 5 '1225' 12
# 6 '1234' 24
# 7 '1333' 4
# 8 '2224' 4
# 9 '2233' 6
variants = {}
for i in [100..999]
c = "#{i}"
sum = parseInt(c[0]) + parseInt(c[1]) + parseInt(c[2])
if c.search(0)<0 and sum is 10
n = c.split('').sort().join('')
variants[n]?=0
variants[n]++
c = 0
for v, i of variants
c++
console.log c, v, i
# 1 '118' 3
# 2 '127' 6
# 3 '136' 6
# 4 '145' 6
# 5 '226' 3
# 6 '235' 6
# 7 '244' 3
# 8 '334' 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment