Feb-16-2018, 06:39 PM
(Feb-16-2018, 05:22 PM)Shutcois Wrote: https://hastebin.josephbanks.me/xamohiwenu.py
Quote:som = float(input()) totaal = int(som*100) totaal2 = int(totaal*10000) def sum_to_n(n, size, limit=None): """Produce all lists of size positive integers in decreasing order that add up to n.""" if size == 1: yield [n] return if limit is None: limit = n start = (n + size - 1) // size stop = min(limit, n - size + 1) + 1 for i in range(start, stop): for tail in sum_to_n(n - i, size - 1, i): yield [i] + tail for partition in sum_to_n(totaal, 3): if partition[0] * partition[1] * partition[2] == totaal2 and partition[0] + partition[1] + partition[2] == totaal: c = partition[0] b = partition[1] a = partition[2] break print(f"${format(a/100, '.2f')} + ${format(b/100, '.2f')} + ${format(c/100, '.2f')} = ${format(a/100, '.2f')} x ${format(b/100, '.2f')} x ${format(c/100, '.2f')} = ${format(som, '.2f')}")
Added your code for you :)