fork download
  1. from collections import Counter
  2. def next_step(s):
  3. return ''.join(str(v) + k for k, v in sorted(Counter(s).items(), reverse=True))
  4.  
  5. s = '1'
  6. print s
  7. for _ in xrange(20):
  8. s = next_step(s)
  9. print s
  10.  
Success #stdin #stdout 0.01s 7864KB
stdin
Standard input is empty
stdout
1
11
21
1211
1231
131221
132231
232221
134211
14131231
14231241
24132231
14233221
14233221
14233221
14233221
14233221
14233221
14233221
14233221
14233221