我有一系列问题,其中一些问题可能是相同的。
{"choice":"attributes","text":"Happy"},
{"choice":"attributes","text":"Fun"},
{"choice":"attributes","text":"Enjoyable"},
{"choice":"attributes","text":"Pleasurable"},
{"choice":"attributes","text":"Ecstatic"},
{"choice":"attributes","text":"Sad"},
{"choice":"attributes","text":"Tedious"},
{"choice":"attributes","text":"Annoying"},
{"choice":"attributes","text":"Depressing"},
{"choice":"attributes","text":"Unhappy"},
{"choice":"attributes","text":"Happy"},
{"choice":"attributes","text":"Fun"},
{"choice":"attributes","text":"Enjoyable"},
目前我正在使用 FisherYatesShuffle() 对数组进行随机化,但我真正需要做的是在随机播放列表后确保没有两个连续的项目是相同的,知道吗?
例如,我们永远不会得到
{"choice":"attributes","text":"Happy"},
{"choice":"attributes","text":"Happy"},
编辑以澄清一些问题。必须保留数组中的所有项目。