The following problem is from the chapter on Dynamic Programming by Vazirani et. al.

> 
> [6.6]Let us define a multiplication operation(×) on three symbols a; b; c according to the following table:
> 
> 
> ![Multiplication table](https://i.imgur.com/HcUWS.png)
> 
> 
> Therefore, a × a = b , a × b = b etc.
> 
> 
> Find an efficient algorithm that examines a string of these symbols, say `bbbbac`, and decides
> whether or not it is possible to parenthesize the string in such a way
> that the value of the resulting expression is `a`. For example, on input `bbbbac` your algorithm should return **yes** because `((b(bb))(ba))c = a`.
> 
> 
> 

### Here is my approach:

Map it to the problem of counting the number of boolean parenthesizations as given **[here](https://stackoverflow.com/questions/6701812/counting-boolean-parenthesizations-implementation)**. In that problem, you are given a boolean expression of the form

T *or* F *and* T *xor* T

and you need to find the number of ways of parenthesizing this so that it evaluates to true.

We can think of *or* , *and* , *xor* as operators which follow certain rules (T *xor* F = T etc.) and act on operands taking values T or F.

For our original problem, we can think of a,b,c as operands with multiplication(x) *as defined by the given table* as providing the rules.

Does the above approach make sense or is there a simpler approach ?