Closed mainej closed 6 years ago
Nice work catching that! Thank you for taking the time to open a PR, fix the problem, improve readability, and explain your changes! You're awesome.
Thank you for maintaining a cool little library, and more importantly, for writing about how to use it.
This algorithm was taken from Wikipedia, but there
b
is the upper limit andc
is the mode, whereas hereb
was the mode andc
was the upper limit.More concretely, this code was using the mode as the upper limit and vice-versa, breaking the algorithm. This change keeps the argument order as
[lower mode upper]
but fixes the algorithm.A smaller commit would have been renaming the arguments from
[a b c]
to[a c b]
, to match the Wikipedia definitions. If you prefer that, that's fine, but I think these descriptive names clarify the algorithm slightly.