Comment by binary132

1 year ago

why not just iterate in steps of three over items for each next group? seems a bit contrived.

Because it's a simplified example to demonstrate the problem. If you do as you've described you need three separate assignments. What happens when the number of groups is dynamic? Nested loop? This is suddenly getting a lot more complicated.

  • Yes, that’s what I was saying:

    for each group:

    for i in steps of #groups:

    assign item to this group

    I think that’s a lot easier to comprehend than the modulus trick

    • For a lot of people the modulo approach isn't a "trick", it's just the intuitive way to split items into residue classes. And it's likely a little more cache-efficient.

      1 reply →