From 84d5b5f1015346320fe9a98faabd9ff8652df13b Mon Sep 17 00:00:00 2001 From: 2colours Date: Sat, 11 May 2024 04:09:15 +0200 Subject: PHP solutions for week 262 --- challenge-262/2colours/php/ch-1.php | 7 +++++++ challenge-262/2colours/php/ch-2.php | 16 ++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 challenge-262/2colours/php/ch-1.php create mode 100644 challenge-262/2colours/php/ch-2.php diff --git a/challenge-262/2colours/php/ch-1.php b/challenge-262/2colours/php/ch-1.php new file mode 100644 index 0000000000..c714bc2363 --- /dev/null +++ b/challenge-262/2colours/php/ch-1.php @@ -0,0 +1,7 @@ + count(array_filter($ints, $pred)), [fn ($x) => $x > 0, fn ($x) => $x < 0])); \ No newline at end of file diff --git a/challenge-262/2colours/php/ch-2.php b/challenge-262/2colours/php/ch-2.php new file mode 100644 index 0000000000..bec9137694 --- /dev/null +++ b/challenge-262/2colours/php/ch-2.php @@ -0,0 +1,16 @@ + $value) { + $needed_factor = intdiv($k, gmp_intval(gmp_gcd($index, $k))); + $next_valid = ceil(($index + 1) / $needed_factor) * $needed_factor; + $values_to_check = array_column(array_chunk(array_slice($ints, $next_valid), $needed_factor), 0); + $result += @array_count_values($values_to_check)[$value]; +} +echo $result; \ No newline at end of file -- cgit