Skip to content

Instantly share code, notes, and snippets.

View justinrixx's full-sized avatar

Justin Ricks justinrixx

View GitHub Profile
alert('omg javascript');
/***********************************************************************
* Program:
* Lesson 08, Tic-Tac-Toe
* Summary:
* This program reads, displays, and writes a Tic-Tac-Toe board
************************************************************************/
#include <iostream>
#include <fstream>
#include <cassert>
import sys
"""
These are some look up tables used in translating the words into
hex. They are hash tables that correspond from one string to another
"""
commands = {
'NOP' : '0',
'MOVIR0' : '1',
'MOVIR1' : '2',
@justinrixx
justinrixx / interpolation.cpp
Last active November 23, 2015 16:59
Comparison between binary search and interpolation search
#include <iostream>
#include <cstdlib> // for random
#include <time.h> // for random
#include <algorithm> // for sort
#define NUMITEMS 10000000
#define TARGET 40 // the number to look for
using namespace std;
@justinrixx
justinrixx / random.cpp
Created August 19, 2015 03:12
Generate any number of random numbers. Give the desired number to the program as a command line argument.
#include <iostream>
#include <cstdlib>
#include <time.h>
using namespace std;
void usage(const char * name) {
cout << "Usage: " << name << " followed by the number of random digits to display"
<< endl << "e.g. " << name << " 5" << endl;
}
@justinrixx
justinrixx / swap.cpp
Created May 5, 2015 19:19
A cool hack exposed in the C++ compiler (works with GCC, at least).
#include <iostream>
using namespace std;
int main()
{
int x;
int y;
cout << "Enter x: ";
@justinrixx
justinrixx / output.cpp
Created April 2, 2015 17:25
Given a text file, writes a file containing a cout statement which produces identical output through the output stream as reading the file in a text editor.
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main(int argc, char ** argv)
{
if (argc != 3)
{