Skip to content

Instantly share code, notes, and snippets.

def multiplicationTable(endVal):
for i in range(1, endVal+1):
for j in range(1, endVal+1):
print repr(i * j).ljust(4),
print
@zachelko
zachelko / fizzbuzz.py
Created April 30, 2010 19:33
FizzBuzz
# 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'
typedef struct Node
{
int val;
struct Node * next;
} Node;
void insert(Node** head, Node* toIns)
{
toIns->next = *head;
*head = toIns;
// 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
#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);
#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);
@zachelko
zachelko / badbegin2.cpp
Created April 11, 2010 05:10
STL begin() 2
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);
@zachelko
zachelko / badbegin1.cpp
Created April 11, 2010 05:07
STL begin() 1
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!
@zachelko
zachelko / SoundManager.cpp
Created April 11, 2010 00:04
A simple sound manager for SDL
// SoundManager.cpp
//
// Zach Elko
// 2010
//
// A simple sound manager for SDL.
//
#include "SoundManager.h"
#include "SDL/SDL_mixer.h"
#include "../ResourceManager.h"
@zachelko
zachelko / Vector2d.hpp
Created April 10, 2010 22:39
General-purpose 2d vector class
// Vector2d.hpp
//
// Zach Elko
// 2010
//
// General-purpose 2d vector class
//
#ifndef VECTOR2D_H
#define VECTOR2D_H