Skip to content

Instantly share code, notes, and snippets.

@tom-galvin
tom-galvin / macbeth.txt
Last active August 29, 2015 14:16
Macbeth (removed song)
ACT I.
SCENE I. An open place.
[An open place. Thunder and lightning. Enter three Witches.]
FIRST WITCH.
When shall we three meet again
In thunder, lightning, or in rain?
SECOND WITCH.
@tom-galvin
tom-galvin / Resource.java
Last active August 29, 2015 14:15
Java resource loading helper class
package pw.usn;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.logging.Logger;
@tom-galvin
tom-galvin / c200i.fs
Last active August 29, 2015 14:14
DailyProgrammer Challenge #200i Solution (Metro Meltdown Madness)
open System
type Vec = { x: int; y: int }
type Tile = { pos: Vec; size: Vec; fill: char }
type Grid = { size: Vec; data: char[,] }
/// Creates a Vec from x and y
let vec x y =
{ x = x; y = y }
@tom-galvin
tom-galvin / c200e.cs
Created February 1, 2015 21:36
DailyProgrammer Challenge #200e Solution (Flood-Fill)
static class Program
{
static char[,] GetBoard(Vector boardSize)
{
char[,] board = new char[boardSize.X, boardSize.Y];
for (int j = 0; j < boardSize.Y; j++)
{
string line = Console.ReadLine();
@tom-galvin
tom-galvin / c196h.cs
Created January 10, 2015 10:44
DailyProgrammer Challenge #196h Solution (Precedence Parsing)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Challenge196Hard
{
class Program
{
@tom-galvin
tom-galvin / c196i.cs
Created January 7, 2015 20:27
DailyProgrammer Challenge #196i Solution (Rail Fence Cipher)
static class Program
{
static string Encrypt(string plain, int railCount)
{
string[] rails = new string[railCount];
int i;
for (i = 0; i < railCount; i++)
{
rails[i] = "";
}
@tom-galvin
tom-galvin / c-set.cs
Created January 5, 2015 18:37
DailyProgrammer Exercise: Ready... set... Set!
class Set<T> : IEquatable<Set<T>>, ICloneable
{
private List<T> Members;
private bool Not;
private Set()
{
this.Members = new List<T>();
this.Not = false;
}
@tom-galvin
tom-galvin / c195e.rb
Created December 28, 2014 19:36
DailyProgrammer Challenge #195e
#!/usr/bin/env ruby
def dir(s)
s
.split('/')
.select {|t| !t.empty? }
end
def resolve(p, l)
resolved = []
p.each do |d|
@tom-galvin
tom-galvin / c193e2.sh
Created December 19, 2014 22:58
DailyProgrammer Challenge #193e2
#!/bin/bash
declare -A SUBS=(
['lol']='laugh out loud' \
['dw']='don'\''worry' \
['hf']='have fun' \
['gg']='good game' \
['brb']='be right back' \
['g2g']='got to go' \
['wtf']='what the fuck' \
['wp']='well played' \
@tom-galvin
tom-galvin / c191h.fs
Created December 5, 2014 19:15
DailyProgrammer Challenge #191h Solution (Tricky Stick Stacking)
open System
type stick = { n: int; x1: float; y1: float; x2: float; y2: float }
let stickFromString (s: string) =
let parts = s.Split(',', ':')
let n, x1, y1, x2, y2 =
Int32.Parse parts.[0],
Double.Parse parts.[1],
Double.Parse parts.[2],