Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def build(num, probs):
- probs = sorted(probs)
- res = []
- if num == 1:
- index = probs[0][1]
- res.append(('', index))
- if num >= 2:
- first = probs[0]
- second = probs[1]
- probs[1] = (first[0] + second[0], second[1])
- for i in build(num - 1, probs[1:]):
- res.append(i)
- for i in res:
- if i[1] == probs[1][1]:
- ans = i
- res.append((ans[0] + '0', first[1]))
- res.append((ans[0] + '1', second[1]))
- res.remove(ans)
- break
- return res
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement