Dimitry RandBits 3459
Сагура Николай, 392, сев. филиал RandBits 2890
t1import randomt1import random
22
3def randbits(p, n):3def randbits(p, n):
4    if n > p or n < 1:4    if n > p or n < 1:
5        return 05        return 0
6    ones_positions = random.sample(range(p), n)6    ones_positions = random.sample(range(p), n)
7    x = 07    x = 0
8    for pos in ones_positions:8    for pos in ones_positions:
9        x |= 1 << pos9        x |= 1 << pos
10    return x10    return x
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op