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.
Thanks!
I keep doing the same thing if the first thing I would do would be to make an exact copy. The thing is the argument passed by value is just your local copy and you can do whathever you want with it without having it an effect for the caller. For the caller it matters little whether you take const & and do a copy explicitly or take argument by value. No changes are visible outside of a function.
On x86_64 Linux (this case I presume) size_t is usually typedef for unsigned long. So sizeof(size_t) will be 8 and sizeof(int) will be 4. With size_t you need store how big something is in memory, so it's unlikely be shorter than int anywhere, but it's still wasting memory. At least half of that diffArr array is always empty. That cast from malloc is not needed in C either as (void *) is implicitly converted to any kind of pointer (Unlike in C++).
Thanks for the Kata! It brings back memories. I haven't seen Pascal for like 18 years. :-)
I'm absolutely unable to pass random tests for D. It tells me for example:
But no matter how am I counting I'm unable to find a mistake. I'm looking for duplicate case-insensitive alphanumeric characters. What am I missing?
When it comes to D version, it seems to me, that the sample tests are missing two imports
import solution : findShort;
andimport std.string : format;
. Main tests are fine.Clever it might be. But you better be sure that
p1
andp2
can never point to the same memory location before even thinking about this.I think you have 2 typos in the description on the line:
f(x) = (key_a * x + key_i) mad m
. It should readf(x) = (key_a * x + key_b) mod m
.mod
instead ofmad
andkey_b
instead ofkey_i
.I'm proposing 3 minor changes to C++ version
Please reaview and/or approve.
Rust translation. Please, review and approve.
Nice! I didn't know about
std::clamp
.No reason. It was just the first thing that came to my mind when I was writing it. Subscript notation would be shorter for sure.
You are right. I don't know what I was thinking. :-)
This comment is hidden because it contains spoiler information about the solution
I don't think this is standard C++ (ranges in switch case). Originally GCC extension, perhaps Clang has it these days as well. But don't be surprise if your compiler doesn't support it.