Home
Sign Up
Sign In
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member
Sign In
V2EX
›
问与答
在随机打乱序列时,保证所有元素都不在原本的位置上,有什么优雅的算法吗?
whileFalse
·
Oct 8, 2018
· 1598 views
This topic created in 2770 days ago, the information mentioned may be changed or developed.
保证序列至少有两个元素。
序列
元素
打乱
算法
2 replies
•
2018-10-08 12:27:13 +08:00
1
LxExExl
Oct 8, 2018 via iPhone
多跑几遍?
2
innoink
Oct 8, 2018 via Android
对每一个元素,生成一个可选位置列表,然后随机一个列表项
About
·
Help
·
Advertise
·
Blog
·
API
·
FAQ
·
Solana
·
1503 Online
Highest 6679
·
Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 30ms ·
UTC 17:05
·
PVG 01:05
·
LAX 10:05
·
JFK 13:05
♥ Do have faith in what you're doing.
❯