def make_random_wc_list(size)
  words = TestArray.new(size, :words)
  counts = TestArray.new(size)
  wc_list = Array(size)
  for i in 0..size-1 do
    wc_list[i] = [words[i], counts[i]]
  end
  return wc_list
end

def make_wc_hash_table(wc_list, table_size)

  # create a blank table
  table = Array.new(table_size)
  for i in 0..table.length-1 do
    table[i] = []
  end

  # insert word_counts into the table
  for i in 0..wc_list.length-1 do
    entry = wc_list[i]
    wc_htinsert(table, entry.first, entry.last)
  end

  return table
end

def wc_hash(string, table_size)
  k = 0
  for i in 0..string.length-1 do
    k = string[i] + k * 256 
  end
  return k % table_size
end

def wc_htinsert(table, key, value)
  table[wc_hash(key,table.length)] << [key, value]
end

def wc_htlookup(table, key)
  bucket = table[wc_hash(key,table.length)]
  return wc_llookup(bucket, key)
end

