- https://www.codewars.com/kata/582041237df353e01d000084 Fun with lists: filter.
Started at 22:47 25.08.2020 Tuesday Aug.
Finished at 23:10 25.08.2020 Tuesday Aug. (0hrs 23minutes)
<?php | |
# https://www.codewars.com/kata/582041237df353e01d000084 Fun with lists: filter. | |
function filter($head, $p) { | |
for( ; $head && ! $p($head->data); $head = $head->next); | |
if(!$head) return null; | |
$prv = $head; $node = $head->next; | |
for( ; $node ; $node = $node->next) | |
if($p($node->data)){ | |
$prv->next = $node; | |
$prv = $node; | |
} | |
$prv->next = null; | |
return $head; | |
} |
Started at 22:47 25.08.2020 Tuesday Aug.
Finished at 23:10 25.08.2020 Tuesday Aug. (0hrs 23minutes)