From The Compiler, 7 Years ago, written in Python.
Embed
  1. sizes = [1, 2, 3, 4, 8, 12, 16, 20, 24, 28]
  2. substrings = []
  3. string = "foobar"
  4. sizes.sort(reverse=True)
  5.  
  6. while len(string) != 0:
  7.     for size in sizes:
  8.         if size <= len(string):
  9.             string = string[size:]
  10.             substrings += string[:size]
  11.  
  12. print(substrings)
  13.