Secret Santa - Generating 'valid' permutations

前端 未结 6 917
不思量自难忘°
不思量自难忘° 2021-02-02 08:54

My friends invited me home to play the game of Secret Santa, where we are supposed to draw a lot & play the role of \'Santa\' for a friend in the group.

So, we write

6条回答
  •  南旧
    南旧 (楼主)
    2021-02-02 09:25

    A permutation that maps no element to itself is a derangement. As n increases, the fraction of derangements approaches the constant 1/e. As such, it takes (on average) e tries to get a derangement, if picking a permutation at random.

    The wikipedia article includes expressions for calculating explicit values for small n.

提交回复
热议问题