Skip to content

Instantly share code, notes, and snippets.

View TRManderson's full-sized avatar

Taylor Manderson TRManderson

View GitHub Profile
@TRManderson
TRManderson / Bytelandian-Exchange-1.py
Last active December 16, 2015 07:49
Solution to Reddit's r/dailyprogrammer challenge #121 [Easy] (Bytelandian Exchange 1)
#http://www.reddit.com/r/dailyprogrammer/comments/19mn2d/030413_challenge_121_easy_bytelandian_exchange_1/
def coins (inputCoin):
if inputCoin == 0:
return 1
else:
return coins(inputCoin//2)+coins(inputCoin//3)+coins(inputCoin//4)
@TRManderson
TRManderson / Bytelandian-Exchange-2.py
Last active December 16, 2015 07:49
Solution to Reddit's r/dailyprogrammer challenge #121 [Intermediate] (Bytelandian Exchange 2)
#http://www.reddit.com/r/dailyprogrammer/comments/1a7ca0/031313_challenge_121_intermediate_bytelandian/
def maxValue(coin):
if coin<=1:
return coin
else:
return max(coin,maxValue(coin/2)+maxValue(coin/3)+maxValue(coin/4))
@TRManderson
TRManderson / Sum-Them-Digits.py
Last active December 16, 2015 07:49
Solution to Reddit's r/dailyprogrammer challenge #122 [Easy] (Sum them digits)
#http://www.reddit.com/r/dailyprogrammer/comments/1berjh/040113_challenge_122_easy_sum_them_digits/
def digitalRoot(number):
if number <= 10:
if number==10:
return 1
else:
return number
else:
digitSum=0
for i in str(number):
@TRManderson
TRManderson / Sum-Them-Digits.hs
Last active December 16, 2015 07:49
Solution to Reddit's r/dailyprogrammer challenge #122 [Easy] (Sum them digits) Haskell re-implementation of RDP-122-E.py
#http://www.reddit.com/r/dailyprogrammer/comments/1berjh/040113_challenge_122_easy_sum_them_digits/
digitalRoot :: Integer -> Integer
digitalRoot n = if (n `mod` 9 == 0 && n > 0) then 9 else n `mod` 9
@TRManderson
TRManderson / graph.png
Last active August 29, 2015 14:12
In a meta-post on Lesswrong, Metus suggested someone plot a curve of comments over time, so I did. (see here: http://lesswrong.com/r/discussion/lw/lev/short_meta_should_open_threads_be_more_frequent/)
graph.png
set nocompatible
filetype off
set hidden
set wildmenu
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
"Bundle 'powerline/powerline', {'rtp': 'powerline/bindings/vim/'}
Bundle 'scrooloose/nerdtree'
Plugin 'bling/vim-airline'
@TRManderson
TRManderson / map.cs
Created February 24, 2015 07:11
Map in C#
static IEnumerable<R> Map<T, R>(this IEnumerable<T> seq, Func<T, R> f)
{
foreach (var t in seq)
yield return f(t);
}
@TRManderson
TRManderson / printout.py
Created December 11, 2015 05:18
Simple decorator to print evaluation result
def printout(f):
from functools import wraps
@wraps(f)
def g(*args, **kwargs):
r = f(*args, **kwargs)
print f.__name__+":",r
return r
return g
@TRManderson
TRManderson / check_gh.py
Last active January 28, 2016 02:50
Repeatedly hit the Github status API to see if it's down or not (py2/3 compatible and cross-platform)
from __future__ import print_function
import requests
import os
import time
if os.name == "posix":
def sound():
os.system("play --no-show-progress --null --channels 1 synth 5 sin 440")
else:
@TRManderson
TRManderson / Makefile
Created February 20, 2016 09:52
My AVR makefile for a uni course last year
# Name: Makefile
# Author: Tom Manderson
# Based on https://github.com/obdev/CrossPack-AVR/
DEVICE = atmega324a
CLOCK = 8000000
PROGRAMMER = -c avrispmkii
OBJECTS = project.o buttons.o game.o ledmatrix.o score.o scrolling_char_display.o serialio.o spi.o terminalio.o timer0.o
AVRDUDE = avrdude $(PROGRAMMER) -p m324pa -F
COMPILE = avr-gcc -Wall -Os -std=c99 -DF_CPU=$(CLOCK) -mmcu=$(DEVICE)