Nice read!<p>I've been toying around with a few hypothetical improvements on my machine.<p>For this case:<p>nums = [100, 6, 5, 100, 4, 4]
desired_result = 743<p>My machine finished the original implementation in:<p>07:53<p>I then tried skipping the set of operators and just doing list lookups (figuring the set overhead defeats the advantage when the collection is so small):<p>08:24<p>My next idea was to replace the set lookup with an isinstance() check:<p>09:01<p>My third proposed change is the only one that has given me a speed-up:<p>Moving the list() call of r to inside the try:<p>06:47