title: Fragment words combination
body: <p>I would like to do a conjunction of words where </p>
  
  <pre><code>EG1
  
      input [jason, sonny, nyorth]
  
      output [jason, sonny, nyorth, jasonnyorth]
  
  EG2
      Sample input: [aw, was,poq, qo, soo] 
      Output [aw, was, poq, qo, soo, awasoo, poqo] 
  
  
  EG3
  
      input: [keyboard, ardjimmy]    
      output:[keyboard, ardjimmy, keyboardjimmy]
  </code></pre>
  
  <p>My code is shown below. There's 3 things that I would like to improve on. </p>
  
  <ol>
  <li><p>I don't want to use check and maxNum. I feel like there will be some cases where the 2 variables will cause an error. It also feels like bad programming. </p></li>
  <li><p>My function is not doing exactly what it meant to do. Meaning, if I am given [abb, bba] my function outputs [abb, bba, abba, bbabb] instead of [abb, bba, abbba, bbabb]</p></li>
  <li><p>Lastly, my function does not recurse itself. For example: given the input [ab, ba] the output should be
  [ab, ba, aba, bab] then it should recurse and become [ab, ba, aba, bab, abab, baba] it will keep going to infinity. When I encounter an infinite loop I should handle that but I'm not even close to solving this problem as of yet. </p></li>
  </ol>
  
  <p>For 1) I am not sure how I am going to replace it with. For 3) I haven't even solve 1) and 2) I don't want to make my function recurse itself. It will get all sorts of weird errors. I want to keep my post clean for revision. Also I will bump into unnecessary duplicates if I do recursion. I would appreciate if someone can enlighten me on 3). For now my priority is 1) and 2).  </p>
  
  <pre><code>  #testing = ["jimmy", "myolita", "paizuri", "mybaby"]
  testing = ["ca","abc"]
  
  testing1 = ["mybaby", "myolita", "jimmy", "paizuri"]
  def frags(strings):
      check = 1
      maxNum = 0
      length = len(strings)
      for x in range(0,length):
          for y in range(0,length):
              if x != y:                
                  for i in range(0,len(strings[y])):
                      if strings[x].find(strings[y][:i]) &gt; maxNum:
                          check = 0
                          maxNum = strings[x].find(strings[y][:i])
  
                  if check == 0:
                     toReturn = strings[x][:maxNum] + strings[y]
                     strings.append(toReturn)
                     check = 1
                     maxNum = 0
      return strings
  
  
  
  print(testing)
  print(frags(testing))                            
  
  
  print("   ")
  
  print(testing1)
  print(frags(testing1))  
  </code></pre>