From 0cc1b6c4a40c58f382d2bc9e527ba4c76a766156 Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Sun, 7 Oct 2018 14:41:09 +0800 Subject: [PATCH] fix shuffle --- specs/beacon-chain.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/specs/beacon-chain.md b/specs/beacon-chain.md index 5effc61a9..69c5b521e 100644 --- a/specs/beacon-chain.md +++ b/specs/beacon-chain.md @@ -326,8 +326,8 @@ def shuffle(values: List[Any], # entropy is consumed in 3 byte chunks # rand_max is defined to remove the modulo bias from this entropy source - SAMPLE_RANGE = 2 ** 24 - assert values_count <= SAMPLE_RANGE: + rand_max = 2 ** 24 + assert values_count <= rand_max: output = [x for x in values] source = seed @@ -344,7 +344,7 @@ def shuffle(values: List[Any], break # Set a random maximum bound of sample_from_source - rand_max = SAMPLE_RANGE - SAMPLE_RANGE % remaining + rand_max = rand_max - rand_max % remaining # Select `replacement_position` with the given `sample_from_source` and `remaining` if sample_from_source < rand_max: