sumim #2253(2007/08/17 06:26 GMT) [ Smalltalk ] Rating2/2=1.00
Squeak Smalltalk で。
1 2 3
| bingo | bingo := [:n | (1 to: n) asArray shuffled]. bingo value: 10 "=> #(6 9 3 4 2 1 10 5 8 7) "
Rating2/2=1.00-0+
1 reply [ reply ]
にしお #2255(2007/08/17 06:39 GMT) [ Python ] Rating1/1=1.00
Pythonでも1~nのリストを作ってシャッフルする方法が一番てっとりばやいですね。 >>> bingo(10) [10, 8, 2, 7, 4, 5, 3, 6, 1, 9]
1 2 3 4 5
def bingo(n): from random import shuffle result = range(1, n + 1) shuffle(result) return result
Rating1/1=1.00-0+
[ reply ]
sumim
#2253()
[
Smalltalk
]
Rating2/2=1.00
Rating2/2=1.00-0+
1 reply [ reply ]