Red envelope algorithm Given a specific number of people and a total amount, everyone gets a share, and everyone’s amount is random. So the allocation has to be limited such that the maximum amount cannot exceed the average value and the minimum amount is 1 cent. The algorithm is as follows: