First time here? Check out the FAQ!
answered 2020-04-19 10:34:55 +0100
More straightforward
sage: sum = 15 sage: xmin = 1 sage: xmax = 9 sage: ymin = 1 sage: ymax = 9 sage: for x in range(max(xmin, sum-ymax), min(xmax, sum-ymin)+1): ....: print(x, sum-x) 6 9 7 8 8 7 9 6