Question: C++ code help A wordsnake, is a collection of words that have been placed in such an order that each consecutive word has a prefix
C++ code help
A wordsnake, is a collection of words that have been placed in such an order that each consecutive word has a prefix that is identical to the suffix of the preceding word. For our purposes, we require that the length of the matching prefix/suffix be greater than one. The quality of a wordsnake is based on its score. Wordsnakes are assigned a score which is the sum of the score of each the word in the snake. Each words score is the square of the number of letters in the overlap with the preceding word.
For example, the words "house" and "sea" have an overlap of 2 letters (hence a score of two squared or 4) in the given order because the suffix "se" of "house" is the prefix of "sea". On the other hand "beret" and "timber" have an overlap of 1 (and score of 1) in the given order because of the letter "t" but have an overlap of 3 (and score of 9) in the reverse order because of the letters "ber".
If at least one wordsnake of length 2 or more words exists in the word list, then a wordsnake will be found. The wordsnake contains only words from the given word list. Each consecutive word in the wordsnake has a greater than one length prefix identical to the preceding words suffix. No word in the wordsnake appears more than once.
Step by Step Solution
There are 3 Steps involved in it
To solve this problem we want to write a C program that constructs a wordsnake from a list of given words The wordsnake needs to meet certain criteria for overlapping words where each consecutive word ... View full answer
Get step-by-step solutions from verified subject matter experts
