function to return integer value of i - th character in the string
static int charVal ( string s , int i ) { if ( s [ i ] == '0' ) { return 0 ; } else if ( s [ i ] == '1' ) { return 1 ; } else { return 2 ; } }