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 seems to be a recurring theme in many of these kata as of late; saw numerous issues reported and was afraid I would start working on a solution and encounter a test case with a negative number in it, so decided to check discussions before starting just in case.
This comment is hidden because it contains spoiler information about the solution
I think the hardest part of this problem is figuring out an algorithm to generate all permutations of a string of any length.
I finally figured out a solution. So I do have a check at the start
if (snail_map.empty())
which passes over the size 0 matrix. But when it came to a matrix of size 1 it kept throwing out that exception. So I added another check inside to see if the matrix of size 1 is empty as shown below.That was the only line of code I added to get the program to work through the Codewars test.
EDIT: So I just reread the description and I guess my smooth brain didn't pick up on the hint at the bottom about how the 0x0 matrix is represented. Seriously though, I think it would make more sense to say a 1x0 matrix because the way most people understand
NxN
is[the number of vectors]x[the number of ints in a vector]
.Looking at your code, that check seems to happen too late. Why not take care of this case at the start of function?
It's most probably an exception thrown by
at
, wheni
is out of range of whatever thesnail_map[leftRightCount]
is.snail_map
is not empty, butsnail_map[leftRightCount]
is smaller thani
.This comment is hidden because it contains spoiler information about the solution
More of a snake than a snail if you ask me
words can't describe how I feel after refactoring my code at least four times over 3 days to arrive to pretty much this answer.
Probably due to the time complexity of your solution. I'm currently working on this kata and came up with a solution that works, but it takes too long after trying 100000! and 1000000000!. So, got to figure out a more efficient way to code the solution now.
If you have an IDE for java set up, you can make a test case like {2, 2, 2, 6, 6} or {2, 2, 2, 3, 4}, step through your code, and look for what goes wrong causing the result not to equal 200.
This comment is hidden because it contains spoiler information about the solution
I'd say it does provide all the info it needs when it says assume the roman numerals will always be valid inputs. So you have to make a solution that handles every possible combination of roman numerals - and as already mentioned you probably will have to research sometimes to learn the ins and outs of a topic that you are not necessarily knowledgeable in when coding e.g. if you were doing game programming you may need to do some research on physics formulas depending on what you are trying to do.
I find the description for what is valid in this kata not specific enough. I thought of a scenario where "[][()]" could be an input and can only assume it would be valid since it is a combination of the first two listed valid examples.
Oh, I like this solution. It changes the char 'c' to lower case and confirms its value is within 'a' to 'z'. Then it gets the numeric value of the char, subtracts 'a' from it (since each letter's numerical value sequentially follows), and then adds 1 to satisfy the requirement of the kata (since a-a=0 or z-a=25).
Loading more items...