We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1f59980 commit cb30881Copy full SHA for cb30881
Easy/1678. Goal Parser Interpretation/solution.php
@@ -0,0 +1,32 @@
1
+<?php
2
+class Solution
3
+{
4
+ /**
5
+ * @param String $command
6
+ * @return String
7
+ */
8
+ public function interpret($command)
9
+ {
10
+ $result = '';
11
+
12
+ $length = strlen($command);
13
14
+ for ($i = 0; $i < $length; $i++) {
15
+ if ($command[$i] === 'G') {
16
+ $result .= 'G';
17
+ } elseif ($command[$i] === '(') {
18
+ if ($command[$i + 1] === ')') {
19
+ $result .= 'o';
20
+ $i++;
21
+ } else {
22
+ $result .= 'al';
23
+ $i += 3;
24
+ }
25
26
27
+ return $result;
28
29
+}
30
+// Example usage:
31
+$solution = new Solution();
32
+echo $solution->interpret("G()(al)") . "\n";
0 commit comments