Ad
  • Custom User Avatar
    sum_pairs([0, 0, -2, 3], 2)
    #  there are no pairs of values that can be added to produce 2.
    == None/nil/undefined (Based on the language)
    

    Yes, you did, but not before using [] and that's why you get the error. Move that if up.

  • Custom User Avatar

    Use p winning_pair to see its value. At some point it is nil and you try to access it with []

  • Custom User Avatar

    No, draw the example as a bar chart, the first number is 7, the next one is 9 (higher than 7), the next one is 6 (lower than 9), and so on. They alternate between higher and lower. So for a given element, except for the ones at each end, the numbers immediatly before and after are both higher or lower than the number itself.

  • Custom User Avatar

    that being said, without a slight imbalance we would never had a big bang

  • Custom User Avatar

    the universe has a way of balancing things out

  • Default User Avatar

    Which language are you working in?

    Can you add a print statement/console log to your Codewars solution, that shows clearly what your code is returning for this input? Right now it's impossible to help you debug and hard to say if error is with tests, or maybe you are reading logs incorrectly and if so maybe it is your code that is returning "" etc.

    For example, I find the solution to be:

    input: ["773256782953519667796", 7]
    
    answer = 732567729535186977669
    

    Does your code produce this answer?

  • Custom User Avatar

    Sorry, but your code is wrong, and that's not a kata issue. It returns true for ['n','n','n','n','n','e','e','e','e','e'] for instance. Added a couple of fixed tests to avoid your wrong solution passing by chance.

  • Default User Avatar

    @AlexDRichards - if you read the Troubleshooting guide it means:

    1. insert a line in your code that prints to console the argument that your function receives. So here, you are being passed an URL string - let's say it's called "input_URL_string" in Ruby, I don't know exactly: then in your code just after the function definition include a line like console.log(input_URL_string), or however you do this in Ruby language.

    2. now press Attempt as usual - each time your code is run in a Codewars test, it will display in the Codewars console on your screen the contents of the input that was received for that test (both the ones that your code passes and the ones that fail); so in this kata you will see a bunch of strings representing URL names appearing in your console.

    3. look in the console for the Red messages, and now you can see the inputs which caused your failed tests

  • Custom User Avatar

    Print function argument to console.

  • Custom User Avatar

    It may be that the tests are expecting a specific named function to be defined, but the compile process is determining it hasn't been defined/created.

    Have you tried renaming your function to 'sum_pairs' to see what happens?

  • Custom User Avatar

    Use puts word for ruby, then the same thing written in the docs applies.

  • Default User Avatar

    Hi @AlexDRichards - I just solved this to resolve this query; I agree that the description isn't 100% clear - there are many comments already in Discourse below about this - but you should be able to work out from the given Tests in your language what the expected behavior is? Or are there no examples in your language?

    Here is a clearer example hopefully:

    input:
    "    A b  C   " <- space pattern from left to right is 4,1,2,3 
    
    output:
    "   c  B a    " <- space pattern from left to right is now 3,2,1,4
    
  • Default User Avatar

    Hi @AlexDRichards - I just solved this kata to see; the answer is that we are considering prime factors with multiplicity.

    So for example, n = 8 = 2*2*2 has only 2 as a prime factor, but with multiplicity 3, so its PrimeFactorsSum(pfs) according to kata requirements is 2+2+2 = 6.

    For n = 12 = 2*2*3 we get 2+2+3 = 7 etc.

  • Default User Avatar

    Hi @AlexDRichards and welcome to Codewars! Read the section on Printing Inputs in the Troubleshooting guide here

    In this case, the input is a hashmap/object users so - however you print to console in Ruby, you should have a line in your main program code as printToConsole(users) or whatever the command is in your language.

  • Default User Avatar

    Hi @AlexDRichards - read the section on Printing Inputs in the Troubleshooting guide here

    In this case, the inputs are arrays a and b so - however you print to console in Ruby, you should have a line in your main program code as printToConsole(a,b) or whatever the command is in your language.

    You will then see the input arrays in the Codewars console.

  • Loading more items...