Skip to content

Instantly share code, notes, and snippets.

View goakley's full-sized avatar

Glen Oakley goakley

View GitHub Profile
@goakley
goakley / coingame.hs
Last active December 14, 2015 12:38
Plays a "Coin Game". The game starts with a stack of coins. Each turn, a player splits a stack into two stacks that must be of two different heights. The game ends when no more stacks can be split, and the person whose turn it is is marked the loser.
import Data.List (elemIndex)
import Data.Maybe (fromJust)
-- A pile of coins is just an Int describing how many coins are in the pile
type CoinPile = Int
-- A state in the coin game is just a number of piles
type CoinState = [CoinPile]
-- A player is either Me or You
data Player = Me | You deriving (Eq)
@goakley
goakley / resume.c
Created January 30, 2013 01:50 — forked from klange/_.md
#include <stdio.h>
#include <time.h>
/* TODO: resume.h */
typedef struct {
char * company;
char * location;
char * title;
@goakley
goakley / linus.c
Last active December 10, 2020 00:34
In response to: http://meta.slashdot.org/story/12/10/11/0030249/linus-torvalds-answers-your-questions An explanation of the two different types of singly-linked list removal explained by Linus Torvalds, using the variable names introduced here: http://stackoverflow.com/questions/12914917/
#include <stdio.h>
typedef struct ll {
int value;
struct ll *next;
} ll;
void print_list(ll *list_head)
{
@goakley
goakley / find.c
Created October 11, 2012 02:36
FIND UNION
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef ENOMEM
#define ENOMEM 12
#endif
@goakley
goakley / qmc.py
Created September 30, 2012 17:43
Q-MC Algorithm
#!/usr/bin/env python
import sys
import math
import re
""" Find the index of the single difference between two strings """
def find_char_difference(str1, str2) :
if len(str1) != len(str2) :
return None;