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 dont make sense. what if the array has 100M and the 1st item is the largest one?
You're a genius I haven't found the solution when I saw yours it was clear as hell thank sir or mame !
Sorry I thought that we need to check $n first.
The Kata definition is:
Build a function that returns an array of integers from n to 1 where n>0.
You need to check first if $n is greater than 0
This comment is hidden because it contains spoiler information about the solution
Could someone explain what's the logic has been used here?
Thanks, i'm overcompensating :)
parentheses are not required here
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]
.Based on the older comments on the discussion chain, it sounds like the test cases didn't originally match with the kata description (i.e. the random tests could test the solution with parameter value 0).
Why start the range at 0?
Must have gotten lucky is the 2 test cases checked against (50/50 in this case);
min() is just as likely. Still possible to use both of them together for a one-liner ternary though to be more complete.
How does this one work?
+1
Loading more items...