4 ms·
The solution given is incorrect. It yields 29 white balls, while the following yields 35. 1 jar1:2 2 3 jar2:3 4 5 6 jar1:2 jar2:4 7 8 9
by tlb 16y ago
The solution given is incorrect. It yields 29 white balls, while the following yields 35.
1 jar1:2
2
3 jar2:3
4
5
6 jar1:2 jar2:4
7
8
9 jar2:6
10
11
12 jar1:11 jar2:3
13
14
15
- ciju 16y agois there a need for jar2:3 at line 12 ?
- Natsu 16y agoDoesn't seem like there is. Also, is my count wrong, or does that only produce 31 white balls? It's still more than the 29, though.
- MtL 16y agoWe have 5 from the start. Start producing 4 more (2 jars) at timestep 1. Start producing 4 more at timestep 6. Start producing 22 more at timestep 12. 22 + 4 + 4 + 5 = 35
- Natsu 16y agoOh, I did it by hand (and I was checking all the balls). I just missed one of the +4s somehow. I wonder how efficient people can make this. I've envisioned all kinds of test cases that crank up the branching factor, require that you find solutions even if you have to trade away white balls for them and other such things. Just because he made them positive integers doesn't mean that there are no ways to punish solutions that won't scale or those that don't always find optimal solutions.
- Natsu 16y agoHonestly, I wish I were on the other end of this. I wonder how many solutions I could find test cases to break even assuming I play nice and allow only positive integers? Yes, I really did imagine all kinds of cases involving zero time and negative time rules (or having zero time to produce anything) and tried to conform them to the spec, but most of them conflict with the output requirements. Not all, though...
- jaekwon 16y agoThanks for your input Natsu, I edited the puzzle to require positive integers.
- jaekwon 16y ago:) you are correct.
- silvajoao 16y agoCare to elaborate? Is the solution presented in the original article incorrect? BTW, the original solution yields 27 whites: 5 from the start, and then jar1 is used 2+3+3+3=11 times, yielding 22 more. I noticed the solution in the article is in a "steady state", that can produce 6 whites every 3 steps, or 2 whites per step. The better solution by tlb produces 26 whites in 8 steps, but I didn't check whether it is sustainable (in the sense that after those 8 steps we have enough material to start over). It's an interesting problem, and I couldn't even model it after a first glance using a graph or linear programming. Will try again later :)
- jaekwon 16y agoThe sample solution on the original article is incorrect.