Тимофей Сухорученков, 418 группа RandBits 2739
Nikita_luk RandBits 3390
f1import randomf1import random
22
3def randbits(p, n):3def randbits(p, n):
n4    if n > p or n == 0:n4    if n > p or n < 1:
5        return 05        return 0
t6    ones_positions = random.sample(range(p), n)t6    positions = random.sample(range(p), n)
7    num = sum((1 << pos for pos in ones_positions))7    result = sum((1 << pos for pos in positions))
8    return num8    return result
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op