Jan-17-2021, 09:54 PM
Yeah, this is small enough that there's only 11^4, or less than 15000. So brute-force is fine. You could instead brute-force through the first 3, then pick the 4th that matches.
from itertools import product items = [x/10 for x in range(11)] matching_sets = (x for x in product(items, repeat=4) if 0.99 < sum(x) < 1.01) for answer in matching_sets: print(f"a, b, c, d = {', '.join(str(x) for x in answer)}")