Earn extra honor and gain new allies!
Honor is earned for each new codewarrior who joins.
Learn more
  • In its current state I would rate this as 7 kyu at most.

  • 👌

  • Thank you, that's a good spot. It seems I might need to keep an abacus next to me. I've edited the translation.

  • The random test generator only produces integers in the range -1_000_000, 1_000_001. Sounds like you meant to set the range between -1_000_000_000, 1_000_000_001

  • Apologies, I only looked at this kata again today. I didn't receive a notification of your comment as it wasn't labeled as Issue.

    I'm not sure I follow though, can you expand? I'm trying to understand where the expectation of an i32 comes from.

    The solution setup currently takes a u8 for the length parameter and returns u64, so I expected the tests to infer that type and I didn't get any of the above warnings for my own solution either. I'm not sure why yours is returning i32.

    fn count_patterns(from: char, length: u8) -> u64 {}
    
  • Apologies for pinging you Wisdou, feel free to ignore.

    KenKamau, this was a fun kata to solve. I thought I'd give translating this to Rust a shot, but — based on the assumption that the JavaScript version is the original? — there are a couple of parts in the random test that I do not fully understand. I'm hoping you would be willing to explain part of it? To walk you through it, see below:

    var leng = "abcdeghijklmnopqrstuvwxyz".repeat(_.random(1, 500)) 
    

    It is my understanding that the above repeats the string abc..xyz by a random amount from [1, 500], as lodash's upper bound is inclusive.

    var st = leng[_.random(0, leng.length)]
    

    The variable st seems to hold a random character from the repeated string.

    var a = '*' + st, b = st + '*', c = '*' + leng[-1], d = leng[-1] + '*';
    

    This is what I do not understand. I'm not sure what leng[-1] does, as from what I understand this gives one undefined on a String in JavaScript? Was this perhaps supposed to be leng.slice(-1) to get a single character from the String's end?

    While taking note of your above feedback, are the Java and C# translations up to par as of right now and can I incorporate code from these into the translation I'm working on?


    If there's a better place to discuss this, I'd like to know! I don't think Codewars has a messaging system built in and raising an issue seemed excessive, as it is not related to solving the kata.

  • Thank you! That's a wonderful post. Bookmarked!

  • Rust translation kumited! :-)

    It appears the random tests for JavaScript do not test for negative integers. I've included negative and positive integers in the random tests for Rust, both ten digits long.

  • Haha, seems we arrived at a nearly identical solution :-)

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

  • Loading more items...