HI im new here, i would like to ask the code for generating words in random letters..
i have a 5x5 dimension of textboxes, each textbox is randomizing as the button1 was clicked,how am i supposed to generate words with the given random letters??pls help me , teach me the logic plzzzz...

note: generating words are like playing word factory where in you could not repeat on the letter that you have used..

Dani AI

Generated

As raised by , the task is to produce dictionary words from a 5x5 letter grid where a letter cell cannot be reused in a single word. 's comment about randomizing the grid is the setup; the core problem is the search. Two common rule-sets change the approach: either (A) any subset/permutation of the 25 letters may form a word (no adjacency requirement), or (B) words must be traced through adjacent cells (Boggle‑style). Choice of rule affects both correctness and performance.

For the subset/permutation case, the most efficient technique is dictionary filtering by letter counts: build a frequency table for the 25 letters, then scan a word list and accept any word whose letter-frequency vector is component-wise <= the grid vector. This is simple, memory-friendly, and runs in O(D * L) where D is dictionary size and L is average word length. Normalize case and strip punctuation before testing. Limiting word length or prefiltering the dictionary to words containing only letters present in the grid speeds things further.

For the adjacency case, use a trie (prefix tree) plus depth-first search from each cell, marking cells visited to prevent reuse and pruning any path whose prefix is absent from the trie. That finds exactly the legal words and scales well with pruning. Example pseudocode:

buildTrie(dictionary)
found = empty set
for each cell in grid:
  dfs(cell, trie.root, visited=set)

function dfs(cell, node, visited):
  ch = grid[cell]
  child = node.child(ch)
  if child is null: return
  mark cell visited
  if child.isWord: found.add(child.word)
  for neighbor in neighbors(cell):
    if neighbor not visited: dfs(neighbor, child, visited)
  unmark cell visited

Practical notes: deduplicate results with a set, enforce a minimum word length, and prefilter the dictionary to characters appearing in the grid to cut runtime. In Visual Basic, arrays for frequency vectors and Dictionary/HashSet for found words work well; recursion depth can be replaced by an explicit stack if needed.

Recommended Answers

All 2 Replies

Hi, Use Rnd() function to generate random number and use any shuffle logic to shuffle words

hello, i had randomized the letters but my problem is, im trying to generate words based on those given letters..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.