title: Python wordsearch generator overlaps words
body: <p>So I have been trying to make a word search grid generator but I've got one problem with this code and I don't know how to solve it. This code generates the word search grid and puts the words from the list in it but sometimes some characters of that word get overwritten by another word (as the position assignment is random and doesn't consider the previously generated indices). I want to fix this but I don't know how...</p>
  
  <pre><code>import string
  import random
  
  height = 15
  width = 15
  def wordsearch(word,grid):
      word = random.choice([word])
      wordlength = len(word)
  
      direction = random.choice([[1,0],[0,1],[1,1]])
      xsize = width   if direction[0] == 0 else width  - wordlength
      ysize = height if direction[1] == 0 else height - wordlength
  
      x = random.randrange(0,xsize)
      y = random.randrange(0,ysize)
  
      print([x,y])
  
      for i in range(0,wordlength):
          grid[y + direction[1]*i][x + direction[0]*i] = word[i]
      return grid
  
  grid = [[random.choice(string.ascii_lowercase) for i in range(0,width)] for j in range(0,height)]
  
  for word in ['hello','red','yellow','green','blue','father','mother','sister','brother','food','drinks', 'cheese']:
      grid = wordsearch(word, grid)
  
  print("\n".join(map(lambda row: " ".join(row), grid)))
  </code></pre>
  
  <p>For example at [1,0] it generates 'green' downwards but the first 'e' got replaced by the word 'blue' generated at [1,2].</p>
  
  <pre><code>[6, 1]
  [12, 7]
  [2, 4]
  [1, 0]
  [1, 2]
  [7, 2]
  [7, 4]
  [11, 6]
  [3, 9]
  [7, 10]
  [5, 0]
  [6, 0]
  t g n v x d c f y r s m d z o
  t r f v j h r h l l o r e v e
  y b y v w t w i e y v f r r m
  z e l b w c e a n e y z c w j
  a n y u l l o m z k s h u z d
  u s i c e i z h o a s e c j r
  l c g n v y k e c t b s g q g
  e f b c p s f r x e h i r t f
  y q p r t h h a z e o s e z h
  o l x b r o t h e r e t r z x
  m f m m n u o f j d s e i e e
  v z u d k x t k o v i r d o k
  l s q o q w a l o o u n y y v
  m q c u r v w i f d d d a p g
  b a h c f o y g g n x e v z s
  </code></pre>