Ad
  • Custom User Avatar

    Add constraints on key_a and key_b to kata description. If key_a * 25 + key_b > 2147483647, naive calculation of f(x) as (key_a * x + key_b) mod 26 can cause overflow.

  • Custom User Avatar

    Yes, you're right. Fixed it.

  • Custom User Avatar

    I think you have 2 typos in the description on the line: f(x) = (key_a * x + key_i) mad m. It should read f(x) = (key_a * x + key_b) mod m. mod instead of mad and key_b instead of key_i.

  • Custom User Avatar

    goofy suggestion

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Yes, my fault, sorry. I really misunderstood the test.
    There are no problems with kata, thanks for the explanation.

  • Custom User Avatar

    as you can see here this requires at least Kotlin 1.5, but this Kata is only available in Kotlin 1.3

  • Custom User Avatar

    The input is not in the error message, as I said before.

    "It should work for random inputs too: 6030 should equal 6003" # < expected answer
    #                                        ^
    #                                     your wrong answer
    
  • Custom User Avatar

    The initial value is: "6003"?

    No, you got this part wrong.

  • Custom User Avatar

    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 that 59884848495583 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 and y 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:

    59884848459853 <- input value of `n`
    59884848495583 <- your current (incorrect) answer
    59884848483559 <- expected correct answer
    
  • Custom User Avatar

    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.

  • Custom User Avatar

    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.

  • Custom User Avatar

    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.

  • Custom User Avatar

    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:

    Python Completions 10347

  • Custom User Avatar

    Initial values:
    59884848495583;
    6030;
    640010;
    917.

    obviously, this is a value that should be less than the initial one

    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...