Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 121 additions & 0 deletions challenges/THE BOX/BOX.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>The... BOX</title>

<!-- CSS Reset, for xbrowser compatibility -->
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.13.0/build/cssreset/cssreset-min.css" />

<style type="text/css">
#container {
/* Center the box */
margin-top: 27px;
margin-left: auto;
margin-right: auto;

/* dimensions */
padding: 5px;
width: 560px;

-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;
}

.box {
float: left;
margin: 5px;
}

.leftnav {
width: 150px;
float: left;
}

#darkgreen {
background-color: #688848;
height: 195px;
width: 140px;
}

#lightgreen {
background-color: #81BB4D;
height: 195px;
width: 140px;
}

.rightnav {
float: right;
width: 410px;
}

#orange {
background-color: #F1AB3C;
height: 400px;
width: 400px;
}


.bottomnav {
width: 560px;
}

#navyblue {
background-color: #2669A8;
width: 290px;
height: 90px;
}
#azure {
background-color: #4794DC;
width: 90px;
height: 90px;
}


.botstack {
float: right;
width: 160px;
}

#skyblue {
background-color: #87BFF4;
width: 150px;
height: 40px;
}
#aqua {
background-color: #B6DBFE;
width: 150px;
height: 40px;
}

</style>
</head>
<body>
<div id="container">

<div class="leftnav">
<div class="box" id="darkgreen"></div>
<div class="box" id="lightgreen"></div>
</div>

<div class="rightnav">
<div class="box" id="orange"></div>
</div>

<div class="bottomnav">
<div class="box" id="navyblue"></div>
<div class="box" id="azure"></div>

<div class="botstack">
<div class="box" id="skyblue"></div>
<div class="box" id="aqua"></div>
</div>
</div>

</div>
</body>
</html>
27 changes: 27 additions & 0 deletions challenges/comprehension/explanation.txt
Original file line number Diff line number Diff line change
@@ -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.
18 changes: 15 additions & 3 deletions challenges/strpos/strpos.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
<?php

function my_strpos(/* arguments go here! */)
function my_strpos($haystack, $needle, $offset=0)
{
# Your code goes here!
// Normalize input
if (gettype($needle) == "integer")
$needle = chr($needle);
elseif (gettype($needle) != "string")
return false;

// Parse
$start = strlen($haystack) - strlen($needle);
for ($i=$start; $i>=$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';
Expand Down