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.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
There is also a
clamp
method in Ruby: https://ruby-doc.org/core-2.4.0/Comparable.html#method-i-clampThis comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Ah, ok, I completely missed that. Thank you for pointing it out!
IMO that line was easy to glance over, or misunderstand. I think I interpreted that they weren't even part of the kata at all.
I think I made that misunderstanding because of a combination of:
Do you think it would be a good idea to add a test cases with non-weighted letters to the sample test cases then? I think that would help people understand.
Unless part of the fun is reading closely, and only finding out about the non-weighted once you do the actual attempt!
For the Java kata, the given sample test cases work fine because they only use the given left vs right side set of characters.
The issue is: the random test cases generate random characters. I think this makes no sense since we don't know the weighted values of those characters. The given letters in the description are weighted in power, so we can't possibly know what to weight a random character. We also aren't told to just treat any other character as a default of one, or anything like that.
So, I think this kata is broken for Java. You can't possibly pass the random tests which are using random characters in the fight.
EDIT: Actually, after trying some stuff, I got it to work by not considering the values of random characters at all. Maybe that's something you should put in the description... I had to guess that other characters could be ignored, then try it out and see if it worked. I had no idea that's what I was supposed to do.
This solution that you've commented on correctly deals with starting and ending spaces. Try it out by forking the solution and adding a test case with leading and trailing whitespace.
Why add the {1}'s when they are already implicit for single characters? It clutters readability without adding benefit.
It's your job to return -1 if you detect that bounce == 1.0... The timeout is an expected failure if the instructions said it shouldn't be 1, right?
I encountered an issue during this kata: the kata itself was fine, there was nothing wrong with the logic of the kata itself. But when running my function, the last lines of my program would not run! This might be a bug in codewars and how it runs java. I have not had this problem for other kata.
See my solution, I've commented the code which should have been able to run.
My solution: https://www.codewars.com/kata/reviews/56a5deb87297212bec00001e/groups/57a27b0c53ba3327cc00012b
In Java, you'd want to test edge cases, such as -2147483648 and 2147483647 for the range of int. Although this might make your suggestion to do it in one line with no conditionals very difficult.
Oh my god why