I was given a task to find the largest number between 1023456789 and 9876543210 that contains all numbers between 0 and 9 exactly once and that can be divided by 11. I wrote a bit of code that technically should have been able to find this number through brute force (Keep in mind this Python 3.6). The code is as follows:
print(max(x for x in range(1023456789, 9876543210) if x % 11 == 0 and '0' in str(x) and '1' in str(x) and '2' in str(x) and '3' in str(x) and '4' in str(x) and '5' in str(x) and '6' in str(x) and '7' in str(x) and '8' in str(x) and '9' in str(x)))
I apologize if the code looks weird as I am still inexperienced. When I tried it with the minimum value, it took about two hours for me to get the result. In this case, the computer was still looking after eight hours. In hindsight, it is logical, it was bound to happen, so now I am looking for an alternative approach to accelerate this process and get my result sooner if possible.