From f023a39d597c1f16dab0dbe107bac7d777f14905 Mon Sep 17 00:00:00 2001 From: sirius strebe Date: Thu, 24 Oct 2013 08:42:35 -0700 Subject: [PATCH 1/6] Created an html replica of BOX-TEST-LAYOUT.png --- challenges/THE BOX/BOX.html | 119 ++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 challenges/THE BOX/BOX.html diff --git a/challenges/THE BOX/BOX.html b/challenges/THE BOX/BOX.html new file mode 100644 index 0000000..744d9a6 --- /dev/null +++ b/challenges/THE BOX/BOX.html @@ -0,0 +1,119 @@ + + + + + The... BOX + + + + + + + +
+ +
+
+
+
+ +
+
+
+ +
+ +
+ +
+
+
+
+
+ +
+ + From 00818c1277f0b84846ed31655b908bddb0b547b8 Mon Sep 17 00:00:00 2001 From: sirius strebe Date: Thu, 24 Oct 2013 08:43:35 -0700 Subject: [PATCH 2/6] Reimplemented strpos --- challenges/strpos/strpos.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/challenges/strpos/strpos.php b/challenges/strpos/strpos.php index 0a4a756..457ae06 100755 --- a/challenges/strpos/strpos.php +++ b/challenges/strpos/strpos.php @@ -1,8 +1,23 @@ =$offset; $i--) { + // If this is 'cheating' let me know and I'll make a better one xD + if (substr($haystack, $i, strlen($needle)) == $needle) + return $i; + } + return false; } $alphabet = 'abcdefghijklmnopqrstuvwxyz'; From 0c5d0104c2cd4cd2d9f358c6d50cf25a9392886f Mon Sep 17 00:00:00 2001 From: sirius strebe Date: Thu, 24 Oct 2013 08:44:10 -0700 Subject: [PATCH 3/6] Wrote up my best guess as to what that function does. --- challenges/comprehension/explanation.txt | 27 ++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/challenges/comprehension/explanation.txt b/challenges/comprehension/explanation.txt index e69de29..55b7b37 100755 --- a/challenges/comprehension/explanation.txt +++ b/challenges/comprehension/explanation.txt @@ -0,0 +1,27 @@ + This basic script will search through an input file "input.txt", and print out each unique "word" containing at least one alphanumeric value (letters or numbers), along with the number of times that word was encountered. + + + The breakdown: +@storage is an initially unpopulated dictionary/associative array. + +%temp holds a buffer of characters, retrieved from "input.txt". + +$temp is an array holding each "word" in the string (meaning, anything delimited by a space). + +%t is a temporary variable representing each word. + +%t.match(/[A-Za-z0-9]+/) is a regex. It returns any matches where the word has alphanumeric values. +I'm assuming here that the forwardslashes are a convention to denote the start and end of a regex expression. + +The next five lines searches the @storage dictionary. If @storage has a key equivalent to %t, it increments the value. Otherwise sets that value to 1. + +The foreach in @storage prints out a line for each key/value representing each word and the number of times it was encountered in "input.txt" + + Language Syntax: +@ are associative arrays +% are strings, or non-array variables +$ are arrays + + + One thing I'd like to note is that %t isn't modified by the regex; the regex only confirms that the word contains an alphanumeric. Therefore, you will see non-alphanumeric words in the output of this script, such as "@mileycyrus", or "_,.-='`a`'=-.,_". + It might be worth doublechecking if the client was looking for a script that printed only english words and their frequency. From f9fc67ee0e3f12c4764cf6d228bcc8a9d40b515f Mon Sep 17 00:00:00 2001 From: sirius strebe Date: Thu, 24 Oct 2013 08:53:18 -0700 Subject: [PATCH 4/6] Removed case-insensitivity, as the original strpos is case sensitive. --- challenges/strpos/strpos.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/challenges/strpos/strpos.php b/challenges/strpos/strpos.php index 457ae06..2884d11 100755 --- a/challenges/strpos/strpos.php +++ b/challenges/strpos/strpos.php @@ -5,10 +5,9 @@ function my_strpos($haystack, $needle, $offset=0) $haystack = strtolower($haystack); if (gettype($needle) == "integer") $needle = chr($needle); - elseif (gettype($needle) == "string") - $needle = strtolower($needle); - else + elseif (gettype($needle) != "string") return false; + $needle = strtolower($needle); // Parse $start = strlen($haystack) - strlen($needle); From 3002c64874b90b90027a276143d4d8b37de111e4 Mon Sep 17 00:00:00 2001 From: sirius strebe Date: Thu, 24 Oct 2013 08:53:41 -0700 Subject: [PATCH 5/6] Removed case-insensitivity, as the original strpos is case sensitive. --- challenges/strpos/strpos.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/challenges/strpos/strpos.php b/challenges/strpos/strpos.php index 2884d11..8f8c709 100755 --- a/challenges/strpos/strpos.php +++ b/challenges/strpos/strpos.php @@ -2,12 +2,10 @@ function my_strpos($haystack, $needle, $offset=0) { // Normalize input - $haystack = strtolower($haystack); if (gettype($needle) == "integer") $needle = chr($needle); elseif (gettype($needle) != "string") return false; - $needle = strtolower($needle); // Parse $start = strlen($haystack) - strlen($needle); From 26eeaf235096f447f4ce69132e8ce59cb26eed95 Mon Sep 17 00:00:00 2001 From: sirius strebe Date: Thu, 24 Oct 2013 09:01:44 -0700 Subject: [PATCH 6/6] Added webkit and moz boxshadowing for compatibility --- challenges/THE BOX/BOX.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/challenges/THE BOX/BOX.html b/challenges/THE BOX/BOX.html index 744d9a6..860da9c 100644 --- a/challenges/THE BOX/BOX.html +++ b/challenges/THE BOX/BOX.html @@ -18,7 +18,9 @@ padding: 5px; width: 560px; - box-shadow: -1px -1px 5px #AAA; + -webkit-box-shadow: -1px -1px 5px #AAA; /* for Chrome + Safari */ + -moz-box-shadow: -1px -1px 5px #AAA; /* for Firefox */ + box-shadow: -1px -1px 5px #AAA; /* for Opera 10.5, IE9 */ /* For floating childen */ overflow: hidden;