Boolean String Value

By | September 8, 2017

Given a string consisting of only 0, 1, A, B, C where
A = AND
B = OR
C = XOR
Calculate the value of the string assuming no order of precedence and evaluation is done from left to right.

Examples:
Input :
1A0B1

Output : 1
1 AND 0 OR 1 = 1

Input :
2
1C1B1B0A0
1A0B1

Output :
0
1