Skip to content

Latest commit

 

History

History
 
 

215-double-trouble

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Double trouble

Challenge Description:

Historians have discovered a mysterious lost code that until this day remains undeciphered. Looks like the code dates back to the 5th century AD. Scientists were trying to decipher the code, which could reveal many details about our ancestors’ life, but they failed. Could you help them?
According to the analysis, there can be only 2 letters in the code: A and B. All messages are transmitted in a form of two equal parts (ABAB, AAAA, BABA, and so on).
Some messages are so mutilated that scientists need to know how many correct variants of the messages might exist to decide whether it would make sense to decipher their meaning, and how long it would take. Therefore, you need to calculate the number of possible correct variants for each message.

Input sample:

The first argument is a path to a file. Each line includes a test case containing one message that includes three symbols:
A and B – deciphered code;
* - lost letter;

For example:

ABA*
BAA*
A*A*

Output sample:

Print the number of possible correct variants of each message.

For example:

1
0
2

Constraints:

  1. A message may be from 2 to 70 letters long.
  2. All messages have an even number of letters.
  3. Some messages may be incorrect. In such cases, print 0.
  4. The number of test cases is 40.