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.
PHP should be upgraded to version
8.0
the Elvis operator is not portable though
:)
You should defer calculations of sqrt as late as you can (not do it right away), trying to return as early as you can, and considering various edge cases.
Cool! I haven't seen a ternary used like this.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
What does this kata add that other kata's about primes haven't done before?
I enjoyed everything, it was an awesome challenge.
ready
ready
ready
Very confusing description. (Copy paste the markdown)
Task :
Hello, warrior!
In this kata, you need to complete the function
sum_not_prime
, which takes two parameters :max_prime
.max_num
.and must return an
array
of lengthmax_num
where for each index0 <= i <= max_num -1
:Example :
sum_not_prime(10, 15)
The primes that need to be considered :
$2$
,$3$
,$5$
and$7$
.$p=2$
: [0, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2]$p=3$
: [0, 0, 2, 3, 2, 0, 2+3=5, 0, 2, 3, 2, 0, 2+3=5, 0, 2]$p=5$
: [0, 0, 2, 3, 2, 5, 5, 0, 2, 3, 2+5=7, 0, 5, 0, 2]$p=7$
: [0, 0, 2, 3, 2, 5, 5, 7, 2, 3, 7, 0, 5, 0, 2+7=9]Final result :
[0, 0, 2, 3, 2, 5, 5, 7, 2, 3, 7, 0, 5, 0, 9]
Note :
The description isn't clear. I needed to study the example pretty carefully to figure out what needed to be done. For one thing, it should be clarified that the prime divisor is never added to the element at index 0, despite the fact that 0 % [prime] equals 0.
Loading more items...