if any digit is not 0 , 1 , ( a - 1 ) or a then balancing is not possible
if ( baseForm . get ( i ) != 0 && baseForm . get ( i ) != 1 && baseForm . get ( i ) != ( a - 1 ) && baseForm . get ( i ) != a ) { return false ; }