Skip to content

Instantly share code, notes, and snippets.

@mi6gan
Last active November 18, 2018 15:54
Show Gist options
  • Save mi6gan/78b6a28931ee51cdcb41823c624b2416 to your computer and use it in GitHub Desktop.
Save mi6gan/78b6a28931ee51cdcb41823c624b2416 to your computer and use it in GitHub Desktop.
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