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
114 changes: 114 additions & 0 deletions challenges/THE BOX/thebox.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<!DOCTYPE html>
<html>
<head>
<title>The Box</title>
<style type="text/css">
#container {
width: 630px;
height: 574px;
padding-left: 30px;
padding-top: 27px;
}

#thebox {
width: 550px;
height: 500px;
padding: 10px;
box-shadow: 0 0 2px 2px #CCC;
-moz-box-shadow: 0 0 2px 2px #CCC;
-webkit-box-shadow: 0 0 2px 2px #CCC;
-moz-border-radius: 1px;
-webkit-border-radius: 1px;
-khtml-border-radius: 1px;
border-radius: 1px;
}

#leftspan1 {
width: 140px;
height: 402px;
float: left;
}

#leftspan1 > .darkgreen {
width: 100%;
height: 195px;
background-color: #68884B;
}

#leftspan1 > .lightgreen {
width: 100%;
height: 195px;
margin-top: 10px;
background-color: #81BB4D;
}

#rightspan1 {
width: 400px;
height: 400px;
float: right;
background-color: #F1AB3C;
}

#bottomspan {
margin-top: 8px;
width: 100%;
height: 90px;
float: left;
}

#bottomspan > .darkblue {
width: 290px;
height: 90px;
float: left;
background-color: #2669A8;
}

#bottomspan > .lightblue {
width: 90px;
height: 90px;
margin-left: 10px;
float: left;
background-color: #4794DC;
}

#bottomspan > #rightspan2 {
width: 150px;
height: 90px;
float: right;
}

#bottomspan > #rightspan2 > .darkblue {
width: 100%;
height: 40px;
margin-bottom: 10px;
background-color: #87BFF4;
}

#bottomspan > #rightspan2 > .lightblue {
width: 100%;
height: 40px;
background-color: #B6DBFE;
}
</style>
</head>
<body>
<div id="container">
<div id="thebox">
<div id="leftspan1">
<div class="darkgreen"></div>
<div class="lightgreen"></div>
</div>
<div id="rightspan1"></div>
<div style="clear: both"></div>
<div id="bottomspan">
<div class="darkblue"></div>
<div class="lightblue"></div>
<div id="rightspan2">
<div class="darkblue"></div>
<div class="lightblue"></div>
</div>
</div>
</div>
</div>
</body>
</html>
17 changes: 17 additions & 0 deletions challenges/comprehension/explanation.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
The program starts off by defining the hash/dict/map @storage, initializing it to null.

It then enters a loop which gets a line of text from "input.txt" each iteration, storing it in the scalar variable %temp.

Within each iteration it splits the string up into words and stores them into the array $temp.

A foreach loop then iterates over each word, storing them temporarily in the scalar variable %t.

Inside this loop it checks to see if the word is composed of one or more alphanumeric characters.

If so, it checks to see if the word is a key in @storage. If so, it increments the integer that the key %t maps to. If not, it initializes an integer in @storage to 1, with %t being its key.

After the program has reached an EOF (I'm assuming at least), it iterates over all the key-value pairs in @storage, and prints them ("key value").

In summary, the program reads a text file, calculates the frequency of every word, and then prints out each word and its corresponding frequency.

Note: The @ sigil refers to a hash/dict/map. The $ sigil refers to an array. The % sigil refers to a scalar (in this case, strings).
21 changes: 19 additions & 2 deletions challenges/strpos/strpos.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
<?php

function my_strpos(/* arguments go here! */)
function my_strpos($haystack, $needle, $offset = 0)
{
# Your code goes here!
if ($offset < 0) {
$backtrace = debug_backtrace();
echo "PHP Warning: my_strpos(): Offset not contained in string in " .
$backtrace[0]["file"] . " on line " . $backtrace[0]["line"] . "\n";
return -1;
}
$haystack = substr($haystack, $offset);
if (!is_string($needle)) {
$needle = chr((int)($needle));
}

preg_match('/' . $needle . '/', $haystack, $matches, PREG_OFFSET_CAPTURE);
if ($matches) {
return $matches[0][1];
}
else {
return false;
}
}

$alphabet = 'abcdefghijklmnopqrstuvwxyz';
Expand Down