Support the Repeated Letters
Learn to evaluate duplicate input.
We'll cover the following...
The issue of repeated letters
So far, we’ve left aside the issue of repeated letters. It’s now time to address this problem.
Once again, we'll use a test file (test_word_info.rb)
. The contents of the file are shown below:
Press + to interact
#test_word_info.rbrequire_relative 'word_info'puts word_info('palladium', ['p'])puts word_info('palladium', ['p', 'l'])puts word_info('palladium', ['p', 'l', 'a'])
We used the word “palladium”
because it contains two interesting cases:
Two identical letters following each other.
Two identical letters not following each other.
We also see on lines 3–5 how we can send a collection (marked by the opening and closing square brackets). Here, the collection that we have contains the letters P
, L
and A
as its elements. We can see this in line 5 ...