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.
I've updated the description with a detailed specification of the input.
Fixed spelling mistake in C translation.
Yea, I should've chosen a better name. Thanks :D
I just ported their code to C. I didn't add any extra features to detect foul play.
This comment has been reported as abusive
I agree with you. I was writting a more thoughtful response to your reply, and I just decided to delete it since it would wrap around to say, "I agree with you". I like your insight, though. It would be nice to have more conversations like this with you ;)
Here is a solution to a Kata that did some VERY hacky stuff that I simply adore:
https://www.codewars.com/kata/reviews/581ccf6aed1b8deb8400001d/groups/5e3aad64f4f5a7000101baf4
To avoid allocating a new variable and optimize both memory usage and performance (since no explicit instruction was given to create one), the solution repurposes a predefined
double
variable as a pointer. This works because adouble
shares the same number of bytes as achar
pointer. The trick is that the variable is dereferenced by casting it to avoid **
pointer. Pretty wild, if you ask me! Hehe.I agree with you. As Terry A. Davis once said, compilers are often designed to be idiot-proof rather than teaching people how to program. Code doesn’t need to be a tangled mess of expressions just to show how concise it is, especially when expanding it would result in the same number of instructions. However, I don't fully align with the philosophy of making conditions idiot-proof or simplifying procedures so that those less skilled at reading code can easily follow it. For large codebases, this approach makes sense—it ensures that anyone working on a piece of code can understand it with minimal effort. But when I'm working on a solo project or with someone who can code, I prioritize optimization. Sometimes, I spend a lot of time refining a function, stepping back to think about how I can improve it. This probably doesn't align with most people’s approach, as they tend to write code more quickly but less carefully.
As for other hacks, I know a few that aren't listed on that website, but I’m sure you’re already familiar with them. On the other hand, the website has plenty of things I wasn't aware of, so you definitely shared some useful optimization tips with me.
Most of the solutions I come up with in Codewars are in the pursuit of conciseness and/or performance. Even though this would never fly in an actual codebase, coming up with solutions to simplify code with clever tricks is one of my favorite challenges.
pretty clean haha
This Kata is specifically designed to be solved in the C language, where the use of null-terminated strings (C-strings) is fundamental to the challenge. While I understand the suggestion to make the title more explicit by referencing C-strings, I believe the current title is sufficient. Since this Kata is limited to C, and strings in C inherently follow the null-terminated convention, the title should not cause confusion within its intended context.
I have made a Kata based on the Kumite that I started. If you want to go check it out, here's the link: https://www.codewars.com/kata/66ca80460f2a3f128a865cc5/c
No one is working together on some ultimate programming project in this thread. This is Codewars. Just have fun and do stupid shit. Nobody said this code was an improvement; it's just another submission.
What you did in those two last lines of code is crazy. I am still trying to wrap my head around it.
Prototype should not use const type for parameter
n
in C translation, that makes no sense at all.Loading more items...