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
26 changes: 26 additions & 0 deletions challenges/THE BOX/box.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#content-holder{
width:560px;
margin:25px auto;
border:2px solid rgba(200,200,200,0.7);
padding:5px;
}

#content-holder div div{
margin:5px;
}

#top-row{
height:410px;
}

#bottom-row{
height:110px;
}

#top-row div{
float:right;
}

#bottom-row div{
float:left;
}
24 changes: 24 additions & 0 deletions challenges/THE BOX/boxes.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html>
<head>
<title>Box Challenge</title>
<script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script>
<script type="text/javascript" src="boxes.js"></script>
<link rel="stylesheet" type="text/css" href="box.css" />
</head>
<body>
<div id="content-holder">
<div id="top-row">
<div style="background-color:#F1AB3C; height:410px; width:400px;" onclick="invertColor(this)"></div>
<div style="background-color:#68884B; height:200px; width:140px" onclick="invertColor(this)"></div>
<div style="background-color:#81BB4D; height:200px; width:140px" onclick="invertColor(this)"></div>
</div>
<div id="bottom-row">
<div style="background-color:#2669A8; height:90px; width:290px;" onclick="invertColor(this)"></div>
<div style="background-color:#4794DC; height:90px; width:90px;" onclick="invertColor(this)"></div>
<div style="background-color:#87BFF4; height:40px; width:150px;" onclick="invertColor(this)"></div>
<div style="background-color:#B6DBFE; height:40px; width:150px;" onclick="invertColor(this)"></div>
</div>
</div>
</body>
</html>
24 changes: 24 additions & 0 deletions challenges/THE BOX/boxes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"use strict"

// Gets the colors of a clicked element (split into rgb) and inverts them
function invertColor(element){
var colors = splitColors($(element).css("background-color"));
$(element).css("background-color", "rgb(" + (255 - colors[0]) + ',' + (255 - colors[1]) + ',' + (255 - colors[2]) + ")");
}

// Takes the color attribute of an element in,
// Uses a loop to iterate through all the colors and place them into an array
function splitColors(colors){
var to_return = [];
var start = 4;
for(var i = 0; i < 3; i++){
var end = colors.indexOf(",", start + 1);
// To account for the final color not having a comma after it.
if(end == -1){
end = colors.length-1;
}
to_return[i] = colors.substring(start, end);
start = end + 1;
}
return to_return;
}
7 changes: 7 additions & 0 deletions challenges/comprehension/explanation.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SYMBOLS
@ represents a dictionary
$ represents an array
% represents a string

OVERVIEW
First the program declares a new empty dictionary. Then in a loop, read in a text file into the string temp one line at a time. For each line: separate the line by spaces, putting the result of the split into an array. For each word (string) in the array, check if the word contains only English alphabetical and numerical characters. If it does, check if the dictionary contains a reference to the word. If so, increment the value associated with the word by one; else, add the word to the dictionary with the value one.
31 changes: 28 additions & 3 deletions challenges/strpos/strpos.php
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,8 +1,32 @@
<?php

function my_strpos(/* arguments go here! */)
{
# Your code goes here!
// The default value of offset should be 0, in the event no offset is passed
function my_strpos($haystack, $needle, $offset = 0){
$to_return = false;
$length = strlen($haystack);
$needle_length = strlen($needle);
for($i=$offset; $i < $length; $i++){
if($needle[0] == $haystack[$i]){
// Check to make sure the needle fits in what's left of the haystack
// If it doesn't, no need to comb through the haystack
if($needle_length + $i < $length){
$to_return = $i;
// loop through the haystack
for($j = 0; $j < $needle_length; $j++){
if($needle[$j] != $haystack[$i+$j]){
$to_return = false;
break;
}
}
// We want to break after we find the first instance of the needle
// That way if there are multiple instances of the needle, we get the first
if($to_return != false){
break;
}
}
}
}
return $to_return;
}

$alphabet = 'abcdefghijklmnopqrstuvwxyz';
Expand All @@ -21,3 +45,4 @@ function my_strpos(/* arguments go here! */)

# Should print "bool(false)"
var_dump(my_strpos($alphabet, 'ghk'));
?>