Combinations of two letters

33 Views Asked by At

Find a word of length $N$ such that the word contains either 'H', 'E', or both, but the word should not contain consecutive 'E's. For example, if $N=3$, then the word can be HHE, HEH, HHH, EHH, or EHE but not EEH or HEE.

1

There are 1 best solutions below

0
On

So, first I started by creating a list:

  • N - words
  • 1 - 2 (H, E)
  • 2 - 3 (HH, HE, EH) X(EE)
  • 3 - 5 (HHH, HHE, HEH, EHH, EHE) X(HEE, EEH, EEE)
  • 4 - 8
    etc.

You'll notice the Fibonacci pattern. Take it from here!
It also has to do with binary sequencing.
This is information about the proibited words: https://oeis.org/search?q=1%2C3%2C8%2C19%2C43&language=english&go=Search