You are on page 1of 1

Global Youth Coding Cup (GYCC) 2016 globalyouthcodingcup.

org

Monkey Words
Description:
Some linguists design a simple language system to test how smart monkeys are.
The monkey language is made of 5 letters only, A B C D E. The letters A and E are
called vowels, while the letters B, C and D are called consonants. A sequence of letters
is called a valid monkey word if no two vowels are adjacent and no two same letters are
adjacent. For example, ABA is a monkey word. AEC is not because the two vowels A
and E are adjacent. AAB is not a monkey word because A and A are two same letters
and adjacent. If a monkey can correctly tell if a sequence of letters is a monkey word,
the monkey wins a banana as rewards.

For any N letters long sequence using A B C D E, the linguists would like to know
how many possible monkey words they can make. For example, for any 2 letters long
sequence, there are 18 monkey words: AB, AC, AD, BA, BC, BD, BE, CA, CB, CD, CE,
DA, DB, DC, DE, EB, EC, ED. Note that AE and EA are not monkey words.

For any N letters long sequence, write a program to find out how many possible
monkey words the linguists can make?

Input Specification:
The input will be one positive integer N (0 < N < 17)

Output Specification:
The number of possible monkey words, which are N letters long.

Sample Test Case 1(only the italic text is the input or output)
Input:
2

Output:
18

Sample Test Case 2(only the italic text is the input or output)
Input:
3

Output:
66

You might also like