# Don't ruhs - Overview Body - mistake?

#1

Hi,
in Sarvan Level Don’t rush, there seems to be a mistake.
The result of y mod n should be in the range 0 … n-1

However, the introduction says:

The `modulo` operation returns the remainder after division of one number by another. (CORRECT)
“The `modulo` function must return a value from 0 to `X`, where `X` is modulo operand.” (Should be from 0 to `X-1`)
(…)

The second function `mod40` must return a value from 0 to 40." (Should be from 0 to 39)

I cannot play the level myself (yet), so maybe there is a reason for this.
Or should I go to the Leveleditor and commit a change?

2 Likes
#2

Why do you think so? For example python `range(0, 40)` return 0-39 values.

Sorry, I didn’t get it. Why you can’t play it?

2 Likes
#3

First of all (sorry for missing that), I stumbled on this text while translating, not gaming.
I’m kind of going ahead for a student who is not fluent at English language.
(And I would not spoil the experience for him by gaming ahead). Moreover, it seems that you would need to be subscribed for playing that level.

But back to the question:

I’m adding the full text from the Overview-section here to make it clearer:

The `modulo` operation returns the remainder after division of one number by another.
The `modulo` function must return a value from 0 to `X`, where `X` is modulo operand.
For the current level, it’s enough to use the shortened version of it.

While input argument (`n`) is less than the `X` it returns the input number.
But when `n` is greater or equal to the `X` it must reduce the input number by `X`.

The second function `mod40` must return a value from 0 to 40.
_In the sample code, it works only until `n < 40`. _
But when `n >= 40` it returns a wrong value.
_To complete the function you need to check an input value _
if it’s greater or equal than 40 – `if (n >= 40)`.
If it’s true, then substract 40 – `n = n - 40`.

From:
While input argument (`n`) is less than the `X` it returns the input number.
But when `n` is greater or equal to the `X` it must reduce the input number by `X`.

I would deduce that that the value X never can be returned, as X will be subtracted when the value n is equal or greater X. So if n was X, X would be subtracted an 0 returned.

This is how the modulo function should be working i. e.
the Range of n modulo X would be between 0 and X-1.

So, if I’m not beeing confused compeletely, the above text should be changed from

The modulo function must return a value from 0 to X, where X is modulo operand.
to
The modulo function must return a value from 0 to X-1, where X is modulo operand.

and from
The second function mod40 must return a value from 0 to 40.
to
The second function mod40 must return a value from 0 to 39

I hope my point is somewhat clearer now…

NB: I notice I should rather play the levels first instead of checking the translation in hindsight, but I’d rather not to Kithgard myself…

1 Like
#4

I’m not sure that you’ve read my answer before. In programming and especially in Python when we say “from x to y” mean the interval `[x, y)`, because python `range(x, y)` is `[x, y)` (I hope you know what the square and usual bracket means). For JS is usual pattern `from x to y` is `for (var i = x; i < y; i++)`.

1 Like
#5

Hello Bryukh,

thanks for your answer. I first did not get your point, but after posting I understood what you mean. Thank you!

“from 0 to X” is suposed to be read in the Python-Way as [0,X) . Then it is correct! I was misled as i read the sencence from the non-python view as [0,X].

A clarification might be helpful, especially for beginners, who at this stage probably still are not really sure about how to use ranges etc, and for non-Python user…

But the instruchtions seem correct as they stand.

Thank you and Regards!

2 Likes
#6

Agree. Good point. I will add it in the description. Thanks.

2 Likes
#7

That’s great, thank you! Please also have a look at level/zig-zag-and-zoom where there is a similar description in the overview body.

Regards.

2 Likes
#8

Got it. Will add an explanation there too. Thanks

3 Likes