Python Brute Force Algorithm Geeksforgeeks