Skip to content

Latest commit

 

History

History

130-sequence-transformation

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Sequence Transformation

Challenge Description:

There are two sequences. The first sequence consists of digits "0" and "1", the second one consists of letters "A" and "B". The challenge is to determine whether it's possible to transform a given binary sequence into a string sequence using the following rules:
1. "0" can be transformed into non empty sequence of letters "A" ("A", "AA", "AAA" etc.)
2. "1" can be transformed into non empty sequence of letters "A" ("A", "AA", "AAA" etc.) or to non empty sequence of letters "B" ("B", "BB", "BBB" etc) e.g.

Input sample:

Your program should accept as its first argument a path to a filename. Each line in this file contains a binary sequence and a sequence of letters "A" and "B" separated by a single whitespace. E.g.

1010 AAAAABBBBAAAA
00 AAAAAA
01001110 AAAABAAABBBBBBAAAAAAA
1100110 BBAABABBA

Output sample:

For each test case print out "Yes" if the transformation is possible, otherwise print "No". E.g.

Yes
Yes
Yes
No

Constraints:
The length of a binary sequence is in range [1, 150]
The length of a string sequence is in range [1, 1000]
The number of test cases is <= 50