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.
It's 7 Kyu
@Wei-LiangChew I'm a little late but then the while loop will iterate over with n - 1 = 8 (and so on)
But what if the largest 5-digit number in
digits
doesn't start with 9?without using super, it can't be a best practice
This catches every missing method. Very bad practice.
Regex usually isn't the best for readability but it's a lot cleaner than how I removed the _ and =. I'm new to ruby so bare with me when I ask, are ternary operators prefered? I see them everywhere in the solutions but I've never liked the way read vs a regular if else.
This is short, which is fun. But the regex is nauseating.
I agree with this. This is also related to other suggestions about performance.
Some solutions float to the top as "best practice" or "clever" even though they have clear issues. Negative flags could address this.
Great Job, I just started to learn regex, and I find it really useful ( rather than iterate over each caracter and check), it could be a little faster if you replace .sort.pop for .max, I'm still not sure how regex does it, because in order to find all chunks starting with 9 and 4 more digits it still needs to iterate over all the array, so Im not sure why my solution is slower, maybe because the regex is executed in a binary library rather than interpreted like ruby ?
The same came into my mind when implemented it.
Putting this in the tests on a published kata and running them outputs a canvas with a red rectangle on it. I doubt a live kata based on this would be permitted, because the script tag is scary, which is why I suggested locking that down and offering supported methods.
EDIT: This originally had script tags but, unsurprisingly, Codewars ate them. I followed the canvas tag with valid script tags in the same line.
I can't figure out how to do that, Josh. Doesn't look like you can
console.log
a script tag, to actually write to the canvas?Oh ffs please put some commments on the test case results. I've got a test case failing with a trailing space with no explanation, where a previous test case with a trailing space passed. If you can't explain why my code is failing your tests I can't be arsed completing your kata.
I have seen some kata that may be considered trivia. I have even implemented a kata that could be considered trivia. I would like to see a ranking criteria for kata where the requirements may seem trivial but promote a generalizable concept.
'Best Practices' and 'Clever' are nice ways to flag a solution but there should be a 'Bad Practice' flag too.
So many bad solutions (unreadble but short) get 'Best practice' flags and it's very missleading to anyone trying to learn from other peoples code. Negative flags would help counter this problem but might need a trial just incase we're all secretly trolls.
Loading more items...