if any digit is not 0 , 1 , ( a - 1 ) or a then balancing is not possible
if ( $ baseForm [ $ i ] != 0 && $ baseForm [ $ i ] != 1 && $ baseForm [ $ i ] != ( $ a - 1 ) && $ baseForm [ $ i ] != $ a ) return false ;