Find all the substring that can be made
for i in range ( total ) : NEW_LINE INDENT num = " " NEW_LINE j = N - 1 NEW_LINE while ( j >= 0 ) : NEW_LINE INDENT if ( i & ( 1 << j ) ) : NEW_LINE INDENT num += '1' NEW_LINE DEDENT else : NEW_LINE INDENT num += '0' NEW_LINE DEDENT j -= 1 NEW_LINE DEDENT DEDENT