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.
That is not an excuse :) Other solutions work fine even going past the 8 digit "limit".
"parsing" each command evey time is not efficient, and the test code do this a lot when jumping between lines.
This naive solution of mine (checking only rows) https://www.codewars.com/kata/reviews/599ac698a48343e7b90027e1/groups/63ab134c94973c0001c7aba0
passes all tests. This should not happen.
this is naive solution checking only rows, yet all tests from this kata passes. Poor kata.
ugly code but it's fast :)
for 10 digit string this gives Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /workspace/default/_solution.php on line 20
for 10 digit string this gives Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 67108872 bytes) in /workspace/default/_solution.php on line 11
Failed asserting that two arrays are identical.
(strings vs integers in array)
with PHP8 you get Undefined array key -1 (line 8)
try
getPINs('0123456789')
with this soultion you getFatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /workspace/default/_solution.php on line 34
so it's bad solution performance wise.
You don't need two iterations.
Your solution is faster but eats a lot of memory. At sandbox.onlinephpfunctions.com your solution with n = 5000000 runs of ouf memory.
you spoiled it with that return :)