From f01a960036e90eabb3bb538c96aa9b3149c463f5 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Fri, 14 Mar 2014 22:53:21 +0000 Subject: [PATCH] Fix a bug causing some solutions to be missed, e.g. (16,5). One of these days I'll remember that you have to say range(start,end-1,-1) not range(start,end,-1) to iterate down to and including 'end' in Python. --- partition.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/partition.py b/partition.py index c8c7db7..18a3a3b 100755 --- a/partition.py +++ b/partition.py @@ -128,7 +128,7 @@ def search(n, m): return (m, 1, {(m,):n}, {(m,)*(n/m):m}) best = (0,) for d in xrange(1, n+1): - for k in xrange(m*d/2, int(math.ceil(best[0]*d)), -1): + for k in xrange(m*d/2, int(math.ceil(best[0]*d))-1, -1): result = try_one_minfrag(n, m, k, d) if result is not None: best = (Fraction(k, d), d) + result -- 2.30.2