I want to generate a random number from range [a,b] that is dividsible by N (4 in my case). I have the solution, but is there a better (more elegant) way to do it?
result = random.randint(a, b)
result = math.ceil(result / 4) * 4
Solutions from here: Python: Generate random number between x and y which is a multiple of 5 doesn't answer my question since I'll have to implement something like:
random.randint(a, b) * 4;
I'll have to divide original range by 4 and it's less readable then my original solution