From ce2fde09a034f487cfca52dabb4eed15845f3770 Mon Sep 17 00:00:00 2001 From: somethingweird Date: Tue, 1 Dec 2020 10:29:41 -0500 Subject: C89 --- challenge-089/henry-wong/php/ch-1.php | 24 ++++++++++++++++ challenge-089/henry-wong/php/ch-2.php | 54 +++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 challenge-089/henry-wong/php/ch-1.php create mode 100644 challenge-089/henry-wong/php/ch-2.php diff --git a/challenge-089/henry-wong/php/ch-1.php b/challenge-089/henry-wong/php/ch-1.php new file mode 100644 index 0000000000..4303a961b3 --- /dev/null +++ b/challenge-089/henry-wong/php/ch-1.php @@ -0,0 +1,24 @@ += $N ? 0 : $x; + if (! isset($board[$sy][$sx])) { + // if empty - then assign number + $board[$sy][$sx] = $i; + $y = $sy; + $x = $sx; + } else { + // else go down a row. + $x-=1; + $y+=2; + $board[$y][$x] = $i; + + } + } + } + // clean up sort the key correctly + + for($i = 0; $i < $N; $i++) { + ksort($board[$i]); + }; + ksort($board); + return $board; +} + +print_r(solution(3)); // 3x3 +print_r(solution(5)); // 5x5 \ No newline at end of file -- cgit