Write a Ruby program that extracts unique four-letter sequences from words in a dictionary file.
- The program must generate two output files:
sequences.txt
: Contains four-letter sequences that appear in exactly one word.words.txt
: Lists the corresponding word for each sequence, in the same order.
- Sequences are case-insensitive.
- Numbers and special characters should not be removed.
- Words containing numbers or special characters should not be skipped.
- Sequences must be exactly four letters long.
For example, given the following sample dictionary:
arrows
18th
carrots
give
me
Isn't
2time
The output files would be:
'sequences' 'words'
carr carrots
give give
rots carrots
rows arrows
rrot carrots
rrow arrows
time 2time
- 'arro' does not appear in the output since it is found in more than one word.
- 18th does not appear in the output because it contains numbers.
- 'time' does appear. although it contains a number, it also contains a unique four letter sequence.
For your solution input, use the following dictionary file: https://gist.github.com/seanbiganski/8c657690b75a830e28557480690bb437
Our evaluation considers the following key factors:
- Requirement Fulfillment – The program must meet all specified criteria and function as expected.
- Code Readability – Clarity, organization, and maintainability of the code are crucial.
- Execution Speed – The program should process data efficiently, optimizing performance where possible.
- Additional Enhancements – Feel free to showcase your skills by adding improvements such as:
- A well-documented README
- Meaningful code comments
- Unit tests to validate functionality
- Any refinements that make the program production-ready
Treat the program as if it were part of a real product.