1
$\begingroup$

I want to create an algorithm to build a hex matrix with given: - max n rows - max m collumns - min t rown - min q collumns

containing the specific words from a list: "example", "test", "algorithm".

For example. To build a hex matrix with:

  - max n = 5 rows
  - max m = 6 collumns
  - min t = 5 rows
  - min t = 4 collumns
  - containg words: "orange", "test"

enter image description here

Can anyone point me in the right direction of how to build this type of algorithm? ( C++, C#, Swift, Objective-C)

$\endgroup$
0
$\begingroup$

Represent the Hex as Graph;

  • each node has additional property; has_letter; $T,F$
  • add the first randomly
    • choose starting point on the graph, probably randomly
    • place the letters by DFS or BFS,
    • add the letter into a list $l$.
  • adding another word with one connection, from start

    • from the list find the first letter of the new string that in the middle of another.
    • place the remaining words by DFS or BFS in nodes with $F$ flag.
  • adding another word with one connection, not necessary from the beginning.

    • from the list find the letters of the new string.
    • One part may be on the upper; as corner and almond. if the connection is $o$, alm on the upper,
    • One part may be on the lower, and nd from the previous example.
    • place the upper part with DFS or BFS in nodes with $F$ flag.
    • place the lower part with DFS or BFS in nodes with $F$ flag.

Hope this helps;

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.