Skip to content

Instantly share code, notes, and snippets.

@pedromartinez
Last active March 25, 2022 17:45
Show Gist options
  • Save pedromartinez/7788650 to your computer and use it in GitHub Desktop.
Save pedromartinez/7788650 to your computer and use it in GitHub Desktop.

Write a program which, given a dictionary, generates two output files, 'sequences' and 'words'. 'sequences' should contain every sequence of four letters (A-z) that appears in exactly one word of the dictionary, one sequence per line. 'words' should contain the corresponding words that contain the sequences, in the same order, again one per line.

For example, given the trivial dictionary containing only

arrows
carrots
give
me

The outputs should be:

'sequences'             'words'

carr                    carrots
give                    give
rots                    carrots
rows                    arrows
rrot                    carrots
rrow                    arrows

Of course, 'arro' does not appear in the output, since it is found in more than one word.

For the final solution, read in the following dictionary file: http://bit.ly/1jveLkY

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment