fork download
  1. # These are the characters we will use in generated strings
  2. charset="abcdefghijklmnopqrstuvwxyz0123456789"
  3.  
  4. def numberToString(n):
  5. base = len(charset)
  6.  
  7. # convert the number to base len(charset)
  8. chars=[]
  9. while n > 0:
  10. chars.append(n%base)
  11. n = n//base
  12. while len(chars) < 3:
  13. chars.append(0)
  14.  
  15. # whiten (make random-looking) by modifying each
  16. # character with a hash of the others
  17. hash = 23634562
  18. for i in range(0,len(chars)):
  19. # the char is reversibly affected by previous characters
  20. chars[i] = (chars[i] + hash + (hash//256)) % base
  21. hash = ((hash + chars[i])*31) % 1000000007
  22.  
  23. # do it again in the other direction
  24. chars.reverse()
  25. hash = 23634562
  26. for i in range(0,len(chars)):
  27. # the char is reversibly affected by previous characters
  28. chars[i] = (chars[i] + hash + (hash//256)) % base
  29. hash = ((hash + chars[i])*31) % 1000000007
  30.  
  31. # make the string
  32. return str.join("", [charset[c] for c in chars])
  33.  
  34. for n in range(0,10):
  35. print(numberToString(n))
  36.  
  37. for n in range(46650,46670):
  38. print(numberToString(n))
  39. # your code goes here
Success #stdin #stdout 0.04s 8960KB
stdin
Standard input is empty
stdout
3kc
lvi
2fa
nbv
4vr
lbb
3qp
fvv
wfn
dvc
lw6
2gy
g6v
xqn
e6c
qfm
4sa1
b7yr
sdg6
c4vk
tb8l
55mp
hwjp
a6hn
rcz7
8imq
nzeg
ztnl
gv2q
spbr