title: How to split text without spaces into list of words
body: <p><strong>Input:</strong> <code>"tableapplechairtablecupboard..."</code> many words  </p>
  
  <p>What would be an efficient algorithm to split such text to the list of words and get:  </p>
  
  <p><strong>Output:</strong> <code>["table", "apple", "chair", "table", ["cupboard", ["cup", "board"]], ...]</code></p>
  
  <p>First thing that cames to mind is to go through all possible words (starting with first letter) and find the longest word possible, continue from <code>position=word_position+len(word)</code></p>
  
  <p>P.S.<br>
  We have a list of all possible words.<br>
  Word "cupboard" can be "cup" and "board", select longest.<br>
  Language: python, but main thing is the algorithm itself. </p>