3 ms·
Sure, sure. I wasn't at a computer at the time and didn't pay the closest attention to the problem. Turns out that the brute-force solution involves two for-l
by klyrs 5y ago
Sure, sure. I wasn't at a computer at the time and didn't pay the closest attention to the problem. Turns out that the brute-force solution involves two for-loops, not three, because you'd be a fool if you don't make bread the innermost loop and optimize it away by filling the remaining capacity.
So the N=1k takes about 6.5ms on my desktop, and the N=10k takes a mere 400ms. Only when I try 100k do I need to actually wait, for an egregious 40s.
And, a more trifling note, their variable bounds are too generous...
meat = model.NewIntVar(0, 1 + capacity // 3, 'meat')
beer = model.NewIntVar(0, 1 + capacity // 7, 'beer')
reduces the triple-loop estimate to a mere 47M cases.