Skip to content

Instantly share code, notes, and snippets.

@joaofig
Created July 13, 2023 06:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joaofig/803995bbc8e8a47c86ece3e00ebf9e44 to your computer and use it in GitHub Desktop.
Save joaofig/803995bbc8e8a47c86ece3e00ebf9e44 to your computer and use it in GitHub Desktop.
def expand_seed(h0: int, h1: int,
max_branch: int = 3,
max_length: int = 10) -> list[PredictedPath]:
final = []
seed = PredictedPath.from_seed(h0, h1, max_length)
paths = expand_path(seed, max_branch)
while len(final) < max_branch:
expanded = []
for p in paths:
expanded.extend(expand_path(p, max_branch=max_branch))
paths = sorted(expanded, reverse=True).copy()
filtered = []
for p in paths[:max_branch]:
if p.step == max_length:
final.append(p)
else:
filtered.append(p)
paths = filtered.copy()
return final
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment