Checking the number of bits that are set in the mask
for j in range ( N - 1 ) : NEW_LINE INDENT if ( ( 1 << j ) & i ) : NEW_LINE INDENT cnt += 1 NEW_LINE v . append ( " * " ) NEW_LINE DEDENT else : NEW_LINE INDENT v . append ( " + " ) NEW_LINE DEDENT DEDENT