"Buzzing" Bill is a well respected beaver. He is the hardest working in his home dam. He was a strong beaver and was able to lift more logs than anyone at the dam. Unfortunately Buzzing Bill's career came to an end in a tragic accident. Being such a prominent figure in his town, the Beaver newspaper wanted to write a frontpage story remembering Buzzing Bill. However Beavers have much smaller newspapers than we do and can only fit 4 letters on each line. The newspaper is assigning you to the task of writing some code to output the four letter lines.
The objective: We need some code written that takes in a string as an input, ex: "Big Beaver Buzzing Bill Bite the Bullet" and splits it into four letter segments that can fit on the Beaver newspaper, and outputs the split segments in an array/list/structure
The answer to this question will have an output to the sentence above that looks much like this: [Big,Bea,ver,Buz,zing,Bill,Bite,the,Bul,let]
The output will complete the all of these criterion for beaver readability:
- Keeps 4 letter words or less together, and completely separate from other words, two words cannot occupy the same line— note that the first two indexes is not [BigB,eav]
- It splits words more than four letters and an even number of letters cleanly in two — i.e. do not have [Beav,er]
- Words with an 7 letters should split at the point between the first two identical adjacent consonants, where one consonant occupies the middle spot, if possible. “y” is not a consonant — Buzzing:[Buz,zing] instead of [Buzz,ing], additionally in very rare cases where the there is a triple consonant in the center, ex: “Wallled” would become [Wal,lled] as the split occurs at the first middle pair
- Words with an odd number of letters that do not satisfy rule #3 should be split so that the front of the word contains the extra letter — "Beavers" should be split as [Beav, ers] rather than [Bea,vers]
- Beavers are not very good at reading, so the newspaper will not use any words over 8 letters, and all words will be entirely lowercase letters(only the 26 used in English)
Make the Best of it Busy Beavers!