Skip to main content
4 events
when toggle format what by license comment
Sep 21, 2016 at 17:57 comment added amon @MagicMarbles Good to hear. If you have many items that do not change often, you can speed this up by pre-calculating the dice range for each item and doing a binary search over a sorted list (not sorted by their weight, but by their dice range). This drops the complexity from O(n) to O(log n), but I wouldn't bother for less than 20 values.
Sep 21, 2016 at 17:51 vote accept Magic Marbles
Sep 21, 2016 at 17:51 comment added Magic Marbles An excellent answer, thank you. Also worth noting is that this solution runs a bit faster, to the tune of ~17ms faster than my solution over 100,000 selections with the same input.
Sep 21, 2016 at 6:33 history answered amon CC BY-SA 3.0