Module:MOS: Difference between revisions
use raw gcd instead |
m Replacing the algorithm in `brightest_mode()` with the "Christoffel word walk" algorithm which is always linear time. |
||
| Line 140: | Line 140: | ||
ns = round(ns/d) | ns = round(ns/d) | ||
end | end | ||
local | local current_L, current_s = 0, 0 | ||
local | local result = '' | ||
while | while current_L < a or current_s < b do | ||
if (current_s + 1) * a <= b * (current_L) then | |||
current_s = current_s + 1 | |||
result = result .. 's' | |||
else | |||
current_L = current_L + 1 | |||
result = result .. 'L' | |||
end | |||
end | end | ||
return string.rep(result, d) | return string.rep(result, d) | ||