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.
can someone help me with how we arrive at that pattern?
@sgelmans91
Just counting all combinations doesn't work because values eventually overlap between different letter combinations; the shortest example is
LIIIII == 55 == XXXXXV
, and this is whysolve(6) == 83 != 84
.The whole kata is about thinking and finding the pattern.
.
This comment is hidden because it contains spoiler information about the solution
Thank you!
Hi
newmaidumosa
,yes, it works fine.
Don't forget, that "WORK" is a string literal and constant. Therefore this memory block is immutable (read only). In this case you pass in
const char*
instead ofchar*
. And you getSegmentation fault
trying to change it.For purpose of this kata, the input parameter shoud be a pointer to the char array and not a pointer to the string literal.
Does this actually work properly? or is it a case that it is just written to pass the test here?
I am new to C, but it seems like this would only work with an array of chars rather than an actual string?
I am grateful for any explanation. I am new to this so bear with me.
When I run:
int main(void)
{
char test[5] = "WORK\0";
printf("%s <-- array of chars\n", toLeetSpeak(test));
printf("%s <-- string literal\n", toLeetSpeak("WORK"));
return 0;
}
~/workspace/extra/ $ ./leet
W0RK <-- array of chars
Segmentation fault