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.
Well, the input is defined strictly as
1000 ≤ year ≤ 9000
.See https://www.postgresql.org/docs/current/queries-values.html
The query is roughly equivalent to
select * from (values (''good''), (''ok''), (''bad'')) as t
.There is a memory leak, the
buffer
is not freed. It is missing thefree(buffer);
before thereturn
.This comment is hidden because it contains spoiler information about the solution
I have just made a more concise solution ;) https://www.codewars.com/kata/reviews/57cb045535ef62f92d0000f1/groups/610d7e5b96e25100013cae0d
This solution will fail when given
"0"
as $str.Does not work for the argument
$str = "0"
. Returns empty array, instead of["0_"]
;Indeed, thank you for pointing this out.
Was the last line of your example meant to be
remove_char(str2, str1);
? Your solution would overflow in that case.For example, assuming the
str1
consists of 6 characters (including null terminator) Thestr2
is correctly allocated 4 characters (to fit two less characters). When passed to your implementation of theremove_char
the callstrcpy(dst, src + 1);
writes 5 characters todst
/str2
thus overflowing.The problem is the function overflows when the user calls it with reasonable arguments, ie a valid
src
and adst
with the exact size.The kata description suggests that input will consist of 2 characters or more, so calling
strlen(src)
in this case makes sense.It will overflow, if the dst size is set to exactly fit the trimmed string.
It is not a double array. It is
array[key]
construct, where the array content is'silver' => 10, 'gold' => 5, null => 20
and the key that is accessed is the result of@$bands[3]
.There is no heads-up about not using the built in function for array reversing, at least in the PHP version.
"Output should have 2 digits precision."
Currently, at least in PHP, that is a lie. Do not round the output, or you will fail the test.
Funny how I came up with almost the same strings.
Loading more items...