From 10ef70c467c2ee1c898e038edc4b8e8643a3d5e7 Mon Sep 17 00:00:00 2001 From: 2colours Date: Sun, 5 May 2024 03:27:47 +0200 Subject: PHP solutions for weeks 266 and 267 --- challenge-266/2colours/php/ch-1.php | 14 ++++++++++++++ challenge-266/2colours/php/ch-2.php | 22 ++++++++++++++++++++++ challenge-267/2colours/php/ch-1.php | 8 ++++++++ challenge-267/2colours/php/ch-2.php | 26 ++++++++++++++++++++++++++ 4 files changed, 70 insertions(+) create mode 100644 challenge-266/2colours/php/ch-1.php create mode 100644 challenge-266/2colours/php/ch-2.php create mode 100644 challenge-267/2colours/php/ch-1.php create mode 100644 challenge-267/2colours/php/ch-2.php diff --git a/challenge-266/2colours/php/ch-1.php b/challenge-266/2colours/php/ch-1.php new file mode 100644 index 0000000000..3079fd5dff --- /dev/null +++ b/challenge-266/2colours/php/ch-1.php @@ -0,0 +1,14 @@ + $value) { + @$word_frequencies[$key] += $value; +} + +$solution = array_keys(array_filter($word_frequencies, fn($freq) => $freq === 1)) ?: ['']; +var_dump($solution); diff --git a/challenge-266/2colours/php/ch-2.php b/challenge-266/2colours/php/ch-2.php new file mode 100644 index 0000000000..c8f7064f37 --- /dev/null +++ b/challenge-266/2colours/php/ch-2.php @@ -0,0 +1,22 @@ + [$state[0] + 1, $state[1] && is_row_compliant($row, $state[0], $size)], [0, true]); # is this really worth it? :D +$solution = true; +foreach ($matrix as $row_index => $row) { + if (!is_row_compliant($row, $row_index, $size)) { + $solution = false; + break; + } +} + +var_dump($solution); \ No newline at end of file diff --git a/challenge-267/2colours/php/ch-1.php b/challenge-267/2colours/php/ch-1.php new file mode 100644 index 0000000000..8b6b877a8a --- /dev/null +++ b/challenge-267/2colours/php/ch-1.php @@ -0,0 +1,8 @@ + $acc * gmp_sign($current), 1); +} + +echo 'The sign of the product is ' . sign_of_product(array_slice($argv, 1)); diff --git a/challenge-267/2colours/php/ch-2.php b/challenge-267/2colours/php/ch-2.php new file mode 100644 index 0000000000..c824e95eea --- /dev/null +++ b/challenge-267/2colours/php/ch-2.php @@ -0,0 +1,26 @@ + SCREEN_WIDTH) { + echo "Line $current_line_number: $current_line_content ($current_column pixels)\n"; + $current_line_content = "$current_char"; + $current_column = $current_width; + $current_line_number++; + continue; + } + $current_column += $current_width; + $current_line_content .= $current_char; +} +echo "Line $current_line_number: $current_line_content ($current_column pixels)"; \ No newline at end of file -- cgit