本帖最后由 slore 于 2017-9-13 09:50 编辑
回复 5# 523066680
论糖还是ruby甜。  - [*30..35].sample(6) #从30到35的数组中取样
复制代码
- (1..10).each { p [*30..35].sample(6)}
复制代码 结果:
[34, 30, 32, 33, 31, 35]
[32, 33, 35, 31, 30, 34]
[35, 30, 33, 31, 32, 34]
[30, 32, 33, 35, 34, 31]
[34, 35, 30, 33, 32, 31]
[34, 32, 35, 33, 30, 31]
[33, 32, 30, 35, 34, 31]
[35, 31, 34, 32, 30, 33]
[34, 31, 30, 33, 35, 32]
[33, 31, 34, 35, 30, 32] |