Last active
January 4, 2016 02:09
-
-
Save scollinson/8553582 to your computer and use it in GitHub Desktop.
for a given maximum comparator width, determine a list of comparator stages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MAX_COMPARATOR_WIDTH = 24 | |
def stages(n, max_width=MAX_COMPARATOR_WIDTH): | |
s = [] | |
while n > 1: | |
q = n // max_width | |
r = n % max_width | |
s.append([max_width]*q + [r]) | |
n += (max_width - 1) | |
n //= max_width | |
return s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment