I am working on a problem similar to the one addressed in the old forum. I came across the post from 'SwePeso' but I am not able to understand it completely.
What does this formula 'COALESCE(s.recID / (s.Yak * s.Unq / s.Items), 0) % s.Items' does?
Peter's code isn't a "BIN Stacking" algorithm. It's a permutation algorithm.
Are you really trying to solve a "BIN Stacking" problem because a permutation algorithm probably isn't the way to go for this. The number of permutations grow explosively and if you have more than a handful of items to stack in more than a handful of bins, it could easily take longer than a well written loop.