Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Yes, you did, but not before using
[]
and that's why you get the error. Move that if up.Use
p winning_pair
to see its value. At some point it isnil
and you try to access it with[]
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.
that being said, without a slight imbalance we would never had a big bang
the universe has a way of balancing things out
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:
Does your code produce this answer?
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.@AlexDRichards - if you read the Troubleshooting guide it means:
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.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.
look in the console for the Red messages, and now you can see the inputs which caused your failed tests
Print function argument to console.
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?
Use
puts word
for ruby, then the same thing written in the docs applies.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:
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 only2
as a prime factor, but with multiplicity 3, so its PrimeFactorsSum(pfs) according to kata requirements is2+2+2 = 6
.For
n = 12 = 2*2*3
we get2+2+3 = 7
etc.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 asprintToConsole(users)
or whatever the command is in your language.Hi @AlexDRichards - read the section on Printing Inputs in the Troubleshooting guide here
In this case, the inputs are arrays
a
andb
so - however you print to console in Ruby, you should have a line in your main program code asprintToConsole(a,b)
or whatever the command is in your language.You will then see the input arrays in the Codewars console.
Loading more items...