aboutsummaryrefslogtreecommitdiff
path: root/challenge-262/2colours/php/ch-1.php
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2024-05-13 00:32:17 +0100
committerGitHub <noreply@github.com>2024-05-13 00:32:17 +0100
commit2fd5134e36c0e93e2db8677341b5a064e119d5c6 (patch)
tree59aa7829fe1e7962628bf7617c20d1d0b87cd7c1 /challenge-262/2colours/php/ch-1.php
parent7f79fc198fbb406bf7b29b4725e01346910248bb (diff)
parent77244cdd27ba9369ded9f12d06f495f7dab42d2e (diff)
downloadperlweeklychallenge-club-2fd5134e36c0e93e2db8677341b5a064e119d5c6.tar.gz
perlweeklychallenge-club-2fd5134e36c0e93e2db8677341b5a064e119d5c6.tar.bz2
perlweeklychallenge-club-2fd5134e36c0e93e2db8677341b5a064e119d5c6.zip
Merge pull request #10079 from 2colours/branch-for-challenge-262
Branch for challenge 262
Diffstat (limited to 'challenge-262/2colours/php/ch-1.php')
-rw-r--r--challenge-262/2colours/php/ch-1.php7
1 files changed, 7 insertions, 0 deletions
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 @@
+<?php
+
+const PARENS = ['(', ')'];
+const SQUARE_BRACKETS = ['[', ']'];
+echo '@ints = ';
+$ints = json_decode(str_replace(PARENS, SQUARE_BRACKETS, fgets(STDIN)));
+echo max(...array_map(fn ($pred) => count(array_filter($ints, $pred)), [fn ($x) => $x > 0, fn ($x) => $x < 0])); \ No newline at end of file