News for hackers. Stuff that matters.
Re:programming challenge by tlb on Sunday October 17, 2010 @04:50AM (#1799953)
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
Re:programming challenge by Natsu on Sunday October 17, 2010 @06:00AM (#1800026)
Honestly, 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...

Re:programming challenge by jaekwon on Sunday October 17, 2010 @11:49AM (#1800583)
Thanks for your input Natsu, I edited the puzzle to require positive integers.
Re:programming challenge by jaekwon on Sunday October 17, 2010 @11:39AM (#1800553)
:) you are correct.
Re:programming challenge by silvajoao on Sunday October 17, 2010 @12:10PM (#1800653)
Care 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 :)

Re:programming challenge by jaekwon on Sunday October 17, 2010 @12:39PM (#1800731)
The sample solution on the original article is incorrect.
Re:programming challenge by ciju on Sunday October 17, 2010 @05:56AM (#1800017)
is there a need for jar2:3 at line 12 ?
Re:programming challenge by Natsu on Sunday October 17, 2010 @06:11AM (#1800036)
Doesn'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.
Re:programming challenge by MtL on Sunday October 17, 2010 @06:42AM (#1800069)
We 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

Re:programming challenge by Natsu on Sunday October 17, 2010 @03:02PM (#1801092)
Oh, 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.