Last active
November 18, 2018 15:54
-
-
Save mi6gan/78b6a28931ee51cdcb41823c624b2416 to your computer and use it in GitHub Desktop.
This file contains 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
def generate_question_numbers(distributions, total_number): | |
generate_numbers = lambda S, N: map( | |
lambda s: round( ( N * s ) / sum(S) ), | |
sorted(S) | |
) | |
question_numbers = [] | |
added_number = 0 | |
for i, question_number in enumerate(generate_numbers(distributions, | |
total_number)): | |
added_number += question_number | |
if added_number >= total_number: | |
question_number -= (added_number - total_number) | |
question_numbers.append(question_number) | |
return question_numbers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment