Skip to content

Instantly share code, notes, and snippets.

@basicxman
basicxman / Problem 4 - ECOO
Created March 30, 2011 17:25
All we do is win win win
#!/usr/bin/env ruby
# Problem 4
# ECOO 2011 Perimeter Trees
# Andrew Horsman
class Point < Struct.new(:x, :y); end
class Line
def initialize(x1, y1, x2, y2)
@basicxman
basicxman / Cortex_i2c.c
Created May 6, 2011 17:11
[RobotC] Cortex i2c implementation
#pragma config(Sensor, dgtl1, sda, sensorDigitalOut)
#pragma config(Sensor, dgtl2, scl, sensorDigitalOut)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#define I2C_DELAY_COUNT 300
#define READ false
#define WRITE true
void i2c_delay() {
for (int i = 0; i < I2C_DELAY_COUNT; ++i) {}
@basicxman
basicxman / gist:960223
Created May 7, 2011 05:25
Ian wanted something to dynamically get sets of keys.
require 'pp'
$glob_store = []
def get_key_sets(temp, previous_set = nil)
temp.each_with_index do |value, index|
if previous_set.nil?
new_set = []
else
new_set = previous_set.dup
@basicxman
basicxman / candy_splitting.rb
Created May 7, 2011 23:20
Google Code Jam Qualification Rounds Problem #3
#!/usr/bin/env ruby
data = []
file_data = File.read(ARGV[0]).split("\n")
is_case_line = false
1.upto(file_data.length - 1) do |i|
data << file_data[i].split(" ").map { |n| n.to_i } if is_case_line
is_case_line = (is_case_line) ? false : true
end
@basicxman
basicxman / main.c
Created May 13, 2011 04:59
First Vex Cortex Robot
#pragma config(Motor, port6, rightFront, tmotorNormal, openLoop)
#pragma config(Motor, port7, rightBack, tmotorNormal, openLoop)
#pragma config(Motor, port8, leftFront, tmotorNormal, openLoop, reversed)
#pragma config(Motor, port9, leftBack, tmotorNormal, openLoop, reversed)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
/*
* @author: Andrew Horsman
* @description: First Vex robot with the Cortex microcontroller.
* ~ 2x16 LCD
#!/usr/bin/env ruby
# Brainfuck Interpreter
class Runtime
def initialize(program)
@data = [0]
@data_ptr = 0
@inst_ptr = 0
#!/usr/bin/env io
# LispML (XML Builder)
# Assignment from Seven Languages in Seven Weeks Chapter 2
Builder := Object clone
Builder forward := method(
tag := call message name
temp := Map clone
temp atPut(tag, list)
@basicxman
basicxman / gist:978048
Created May 18, 2011 05:49
First Prolog assignment in Seven Languages in Seven Weeks
book_author('JavaScript The Good Parts', 'Douglas Crockford').
book_author('Seven Languages in Seven Weeks', 'Bruce A. Tate').
book_author('Rework', 'Jason Fried').
book_author('The Little Schemer', 'Daniel P. Friedman').
book_author('Code Complete', 'Steve McConnell').
book_author('Software Estimation', 'Steve McConnell').
book_author('Software Project Survival Guide', 'Steve McConnell').
% Note: These genres are totally inaccurate, but I'm lazy.
book_genre('JavaScript The Good Parts', 'Web Development').
// Original code by Code Jam user SkidanovAlexander, only comments have been added for analysis purposes.
// Analysis done on 05/20/2011
#define _CRT_SECURE_NO_DEPRECATE
#include <stdio.h>
#include <iostream>
#include <memory.h>
#include <assert.h>
#include <algorithm>
" Vim configuration - Andrew Horsman [basicxman]
" Operating system dependent options
if has("win32") || has("unix")
source $VIMRUNTIME/mswin.vim
behave mswin
endif
if has("win32")
:cd C:\Users\Andrew