Ad
  • Default User Avatar

    This solution of mine isn't consistent.

    var code = [5,5,5];
    function tryCode(indications) {
    // TODO : indications are null or a 3-digits array.
    if(indications){
    indications.map(function(e,i){
    code[i] += indications[i];
    })
    }
    return code;
    }

    This is my refactored solution! Codewars is having problems with accepting another solution.

  • Default User Avatar

    Your description needs work

    0 = correct digit
    -1 = higher digit
    1 = lower digit

    I have to interpret your example and not your instructions.
    FIX IT PLZ

  • Default User Avatar

    Preloaded as Fruits[];

    return Fruits;

    It isn't defined.
    Fix this please.

  • Default User Avatar

    Whats the point of lambdas in Ruby?

  • Default User Avatar
  • Default User Avatar

    Here's why I think you got it wrong

    1. your parameter in the function is arr
    2. the array in question is called questions

    I don't believe the code kata inputs the questions array into any function.

  • Default User Avatar

    I don't think you're wording the backstage conditions correctly or they are not very clear:

    Here's what I understood from it at the beginning:
    Backstage should increase in quality += 1 every sell in
    If backstage sell ins are <=10
    they should increase by 2 instead
    If backstage sell in are <=5
    they should increase by 3 instead
    end

    Here you have a backstage with 7sell in, 9 quality. Let's count the sell ins.
    7=>6 increase by 2 quality = 11
    6=>5 increase by 2 quality = 13
    5=>4 increase by 3 quality = 16
    4=>3 increase by 3 quality = 19!!!!!!!!!!

    Thats 4 days. Where the final sell in/day is ending at 3. Going from 7>6>5>4. 2 of those days should be +2 each. The other 2 should be +3 each.
    I know the answer it's testing for is +quality: 2,3,3,3
    But the wording is very vague and confusing.

    Starting items in the store are {Conjured Goblin Axe +5, 7, 13}, {Canned Laughters, 9, 12}, {Priss and the Replicants Backstage Passes, 7, 9}, {Conjured Goblin Axe +5, 9, 38}, {Zero Zone Kevlar Vest +1, 8, 22} and 4 days passed

    OUTPUT:
    Checking item 3: Priss and the Replicants Backstage Passes
    Test Passed: Value == 3
    Not the expected quality value - Expected: 20, instead got: 19

  • Default User Avatar

    What if there's a 12 names in the array? Or 20 names? Your code would break. Refactor it so that it doesn't rely on hardcoding indexes to work.

  • Default User Avatar

    Why would you write a for loop if you're just going to hardcode the indexes???
    This isn't what the exercise was meant for IMO!

  • Default User Avatar

    not even test cases

  • Default User Avatar

    I"m getting a
    "<NoMethodError: undefined method `*' for nil:NilClass> "
    for one of the tests... everything else passes.

  • Default User Avatar

    There are NO FUNCTIONS in ruby I am told. It's a method.

  • Default User Avatar

    I did not see the stipulation. Sorry, but the code should work. Just check for syntax errors!