From: "Jesús Gabriel y Galán" Date: 2012-09-26T18:44:24+09:00 Subject: Re: inject problem On Wed, Sep 26, 2012 at 9:39 AM, Roelof Wobben wrote: > Now refractor the if then 's and I hope I can decline it to less then 5 if > then's. > But that will be difficult. I think you should not structure the code this way. I think you should loop through the counts, finding and removing sets. Something like (pseudocode): while there are sets of 3 ones: remove the set from the hash (h[1] -= 3) sum 1000 to the score end while there are sets of 3 any other pip count: remove the set from the hash (h[x] -= 3) sum 100*x to the score end sum 100 * (remaining number of ones) sum 50 * (remaining number of fives) This way, your code is more simple and robust. For example this will also work if you throw 9 dice, while your current algorithm does not. Jesus.