Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Add constraints on
key_a
andkey_b
to kata description. Ifkey_a * 25 + key_b > 2147483647
, naive calculation off(x)
as(key_a * x + key_b) mod 26
can cause overflow.Yes, you're right. Fixed it.
I think you have 2 typos in the description on the line:
f(x) = (key_a * x + key_i) mad m
. It should readf(x) = (key_a * x + key_b) mod m
.mod
instead ofmad
andkey_b
instead ofkey_i
.goofy suggestion
This comment is hidden because it contains spoiler information about the solution
Yes, my fault, sorry. I really misunderstood the test.
There are no problems with kata, thanks for the explanation.
as you can see here this requires at least Kotlin
1.5
, but this Kata is only available in Kotlin1.3
The input is not in the error message, as I said before.
No, you got this part wrong.
Double reply so you see the updated message: it seems, indeed, that this is due to you reading the error message incorrectly.
You posted in your original message:
"59884848495583 should equal 59884848483559"
and then you said that59884848495583
is the initial value: NO this is your mistake - you are not reading error message correctly.In the statement
x should equal y
-x
is what your code is currently returning andy
is the actual correct answer.As stated earlier - you should add the following to your code:
print(n)
- now you will see what the actual input values you are being passed are.Just to be 100% clear:
Then it turns out that:
"It should work for random inputs too: 6030 should equal 6003"
The initial value is:
"6003"
?The answer is:
"6030"
?Then my code works correctly and everything corresponds to the correct answers, but the kata does not pass.
You most probably read logs incorrectly, and you mistake actual values returned by your solution, with input values.
I changed the way how tests are organized to give better feedback on failure, hopefully this will make it easier for you to spot your mistake.
Of the values that you are showing, only the value
5988...
is a fixed test that we can reproduce easily.However, already you are reading it wrong - you claim the initial value is: 59884848495583
but the test is actually using input: 59884848459853
I have bolded the digits you are getting wrong.
Make sure you are reading tests correctly - also in your code, add a
print(name_of_input)
somewhere if you want to double check.Obviously, you're misreading the logs, the first value in the error message is what your function wrongly returned, not the input value. To see what it was, print it. Not a kata issue:
Initial values:
59884848495583
;6030
;640010
;917
.This is in the sense that the answer to the test already contradicts the task. The answer is less than the original number.
Loading more items...