| Антипова Алёна 425 гр. RandBits 2830 | squizyCake RandBits 4215 | ||||
|---|---|---|---|---|---|
| f | 1 | import random | f | 1 | import random |
| 2 | 2 | ||||
| 3 | def randbits(p, n): | 3 | def randbits(p, n): | ||
| 4 | if not 1 <= n <= p: | 4 | if not 1 <= n <= p: | ||
| 5 | return 0 | 5 | return 0 | ||
| t | 6 | position = random.sample(range(p), n) | t | 6 | pos = random.sample(range(p), n) |
| 7 | num = 0 | 7 | x = 0 | ||
| 8 | for pos in position: | 8 | for i in pos: | ||
| 9 | num |= 1 << pos | 9 | x |= 1 << i | ||
| 10 | return num | 10 | return x | ||
| Legends | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
| |||||||||