| Леушин Илья 528 RandBits 3428 | Володин Платон 511 RandBits 3550 | ||||
|---|---|---|---|---|---|
| f | 1 | import random | f | 1 | import random |
| 2 | 2 | ||||
| 3 | def randbits(p, n): | 3 | def randbits(p, n): | ||
| n | 4 | if n <= 0 or p < n: | n | 4 | if n <= 0 or n > p: |
| 5 | return 0 | 5 | return 0 | ||
| t | 6 | res = 0 | t | 6 | x = 0 |
| 7 | for pos in random.sample(range(p), n): | 7 | for b in random.sample(range(p), n): | ||
| 8 | res |= 1 << pos | 8 | x |= 1 << b | ||
| 9 | return res | 9 | return x | ||
| Legends | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
| |||||||||