This is a good kata for problem solving and requires thinking about the algorithm before starting to write tests /code. Having worked on the combinatorics problems before helped. This is not the perfect kata for TDD. I couldn't come up with a lot of tests.
Updated on May 05, 2013 by Himani
When I first read the case, I thought was not only how to solve the kata but also how to optimize the algorithm to solve the problem efficiently. As usual, my approach to solve a problem starts in a paper. I draw an example of a set of possible weights. Then I play with then to understand the logic behind the measurement operation. After I while, I realize that the possible combinations in the positions and use (or not) of the stones could be modeled like -1 (if it is on the left), 0 (is it is not used) or +1 (if it is on the right). Now I have a way to check if a particular set of weights can generate what quantity of measures. The other part of the problem is the generation of the possible set of weights. The restrictions are that all of the weights have to sum 40 and they are all integers. Using this information I could improve the exploration of the combinations to make it more efficient. This part was challenging, because even when I could found some rules to reduce significantly the exploration, still I believe that more optimization can be done. It was a great kata. Very helpful to think in how to optimize of combinatorial explosion exploration.
Updated on May 05, 2013 by oscaralvaro162
This kata is a good exercise for DRY and readable practice. If we want allow the program to change for different pounds and number of stones, we can't just write 4 layers of loop in our program. To solve this problem, I tried to use recursive function and create trinary system. And it will make the program faster if we eliminate duplicate combinations.
Updated on May 05, 2013 by CarinaZheng
The most interesting part of the problem is to think through it and decompose it to loosely coupled functions. The problem itself is not very difficult. Everything except my code is a little verbose.
Updated on May 05, 2013 by evivrus
It is a good challenge for trying different solutions. While finish the one the code required, it is interested to spend more time and generalize the algorithm so that it can fit to different situations, for example, different weights.
Updated on May 05, 2013 by lydian79
This is a wonderful exercise for brushing up your problem solving skills. I figured out the approach before jumping to solve the problem. Most of my time wasted in searching for small coding issues.
Posted on Mar 21, 2012 by charuaggarwal
It was a nice and challenging problem. Trying different numbers in a notepad document to see what a potential solution could be. I'm not sure whether there's a more efficient way of solving the problem than having many for loops. There's a nice way to figure out whether you can weight an item of a certain weight. It involves iterating each weight through the left side, the right side, and a nonexistent side.
Posted on Mar 21, 2012 by Borys
It's interesting, and has a couple of tricks you have to realize. It is possible to get the right answer without actually getting the right answer, that is, a solution that is general.
Posted on Mar 21, 2012 by Isak Sky
A very nice kata to understand the mathematical and digital concepts in algorithms. It was tempting to go for a brute force, but believe me, finding a solution is much more fun. Kata becomes more tricky when coming up with test cases, but again, think of test cases as a new problem.
Posted on May 06, 2013 by singhprabhjot54