Ad
  • Custom User Avatar

    I may be wrong, but I don't think nested loops will work here.

  • Custom User Avatar

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

  • Custom User Avatar

    Hi Guys,

    Thank you both for spending your time on providing a more clear explanation.
    @awesomead - the code was indeed buggy. I'm currently learning to code in RUST and things are much more different than with other languages (in a positive way, I'd say).

    P.S. - Once I submitted a working variant of my code and saw the solutions of other people - I realized how much more there is to learn. The positive thing here is that I already received some feedback about the fact that very often "clever" solutions are much more difficult to debug in the future... I gues that depending on the point of view - there might actually be some positives to writing without too much of syntactic sugar.

    Enjoy the rest of the day / week.

    Cheers,

  • Custom User Avatar

    Rust translation improved, ready for approval.

    • Added better assertion messages to test suite
    • Moved reference solution into tests module, cleaned up imports.
    • Clarified sample tests via comments
    • Made solution setup compile via todo! macro
  • Custom User Avatar

    The tests are fine. Hobovsky explained the confusion you seem to be having above.
    It seems that your code is simply buggy, in that is trying to unwrap the Result from parse(), which is invalid if the Result is an Error. This is why using unwrap is typically bad habit. Check your numbers before parsing them.

  • Custom User Avatar

    I checked the tests which the creator has made, and it seems that he / she / they are testing 2 different functions

    Not exactly. The kata wants you to perform the so-called "silly addition" every time. It;s just some inputs sometimes result in behavior identical to "normal addition". For example, when you do the "silly addition" with inputs 12 + 44, you will still get 56.

    See if this paragraph is of any help: https://docs.codewars.com/training/troubleshooting#print-input, and maybe raise a suggestion to make assertion messages clearer.

  • Custom User Avatar

    Hi Guys,

    Can someone please help me?

    I've written the code that solves the kata in RUST (I tested it manually with different number combos), but when I "Attempt" the kata officially >>> I get the following result(s):

    =============================================================

    tests::test_big
    assertion failed: (left == right)
    left: 3021499,
    right: 31499
    tests::test_random
    called Result::unwrap() on an Err value: ParseIntError { kind: PosOverflow } at src/lib.rs:53:43
    tests::test_real
    assertion failed: (left == right)
    left: 3,
    right: 13
    tests::test_silly
    Test Passed

    I checked the tests which the creator has made, and it seems that he / she / they are testing 2 different functions:

    • one that solves the kata using normal multiplication;
    • one that solves the kata using the puzzle from the kata;

    Here is what I mean:

    #[test]
    fn test_real_add() {
    assert_eq!(add(2, 11), 13);
    assert_eq!(add(0, 1), 1);
    assert_eq!(add(0, 0), 0);
    }

    #[test]
    fn test_silly_add() {
    assert_eq!(add(16, 18), 214);
    assert_eq!(add(26, 39), 515);
    assert_eq!(add(122, 81), 1103);
    }

  • Custom User Avatar

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

  • Custom User Avatar

    Hi,

    I have the same question as Alexander.

    The wording used in the "Deatils" states >> "a boolean true if ALL rotations of strng are included in arr (C returns 1)"

    How comes a string which contains only 4 of the possible rotations gives us a result of: true? :(

    Regards,

  • Custom User Avatar

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

  • Custom User Avatar

    What's the first number in the array you build?

    Square all numbers k (0 <= k <= n) between 0 and n.

    What's the value of d in the tests you're failing? You can use console.log to print the input values.

  • Custom User Avatar

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

  • Custom User Avatar

    Your code is failing one of the sample tests too, check that, and how you build you array, that'll help.

  • Custom User Avatar

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