Why am I getting dups with random.shuffle in Python?

∥☆過路亽.° 提交于 2019-12-05 14:38:26
Mark Byers

It's called the Birthday Paradox.

According to this formula from Wikipedia:

but replacing 365 with 10! you would only need about 2200 examples to have a 50% chance of a collision, and you are way above that.

Because it's... random! If you want all permutations just use itertools.permutations.

maybe because is RANDOM? Random does not mean does not repeat, it means it is RANDOM, which means theoretically it could return the exact same answer every time, not likely but possible.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!