Hacker News new | past | comments | ask | show | jobs | submit login

That assumes they want an even distribution of apples in each crate. My reading of the problem would suggest that for each apple we should choose a random box and insert the apple into said box.

The question seems like a poorly phrased discussion of the pigeonhole principle.




Well, you can extend the parent's solution by throwing in 9 "end of current box" markers with the 100 apples before randomizing the order, rather than declaring them to be every 10 apples after sorting. This is probably not an efficient solution from a programming perspective, but it's similar how you would count the number of distinct such arrangements in combinatorics.


As you said, not very practical from a programming perspective, but it's an interesting way of looking at the problem. Thanks.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: