This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def multiplicationTable(endVal): | |
for i in range(1, endVal+1): | |
for j in range(1, endVal+1): | |
print repr(i * j).ljust(4), | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Zach J. Elko | |
# | |
# Solution for the programming question listed here: | |
# http://www.codinghorror.com/blog/2007/02/why-cant-programmers-program.html | |
# | |
for i in range(1, 101): | |
multipleOf3 = (i % 3 == 0) | |
multipleOf5 = (i % 5 == 0) | |
if multipleOf3 and multipleOf5: | |
print 'FIZZBUZZ' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef struct Node | |
{ | |
int val; | |
struct Node * next; | |
} Node; | |
void insert(Node** head, Node* toIns) | |
{ | |
toIns->next = *head; | |
*head = toIns; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ResourceManager.cpp | |
// | |
// Zach Elko | |
// 2010 | |
// | |
// Functions as a garbage collector for allocating and releasing SDL resources. | |
// | |
// Supports: SDL_Surface, Mix_Music, and Mix_Chunk. | |
// | |
// It improves program efficiency by only allocating one copy for each |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vector> | |
#include <iostream> | |
using namespace std; | |
int main() { | |
std::vector<int> foo; | |
// Add an item and then obtain an iterator to it | |
foo.push_back(3); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vector> | |
#include <iostream> | |
using namespace std; | |
int main() { | |
std::vector<int> foo; | |
// Add an item and then obtain an iterator to it | |
foo.push_back(3); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
std::vector<int> foo; | |
// Add an item before setting the iterator... | |
// Should work, right? | |
foo.push_back(2); | |
std::vector<int>::iterator iter = foo.begin(); | |
// Add another item | |
foo.push_back(3); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
std::vector<int> foo; | |
// Set the iterator once we've created the container | |
std::vector<int>::iterator iter = foo.begin(); | |
// Add some stuff to it | |
foo.push_back(2); | |
foo.push_back(3); | |
// Use the iterator... oops! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SoundManager.cpp | |
// | |
// Zach Elko | |
// 2010 | |
// | |
// A simple sound manager for SDL. | |
// | |
#include "SoundManager.h" | |
#include "SDL/SDL_mixer.h" | |
#include "../ResourceManager.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Vector2d.hpp | |
// | |
// Zach Elko | |
// 2010 | |
// | |
// General-purpose 2d vector class | |
// | |
#ifndef VECTOR2D_H | |
#define VECTOR2D_H |