By the way, it looks like Allen's code is flawed like my original was. It passes all of the tests, but, for example, if you change test 54 to '0,00,10,1', it breaks. It returns 000 instead of 100. It depends on the order of when combinations are added to $o