Skip to content

Instantly share code, notes, and snippets.

View sixthgear's full-sized avatar

Joshua Cender sixthgear

View GitHub Profile
@sixthgear
sixthgear / map.py
Created June 3, 2013 22:22
Mad Science map class
from noise import perlin_noise as noise
from objects import building
from objects import tree
from pyglet.gl import *
import math
import random
import vector
tile_size = 32
tile_height = 24
def fn(n, c):
num = 0
a = range(1, n/2+1) + (n%2)*[0]
b = range(n, n/2, -1)
for _ in range(n-1 + n%2):
for aa, bb in zip(a, b):
if aa and bb:
yield (num/min(c, n/2)+1, aa, bb)
num += 1
a, b = a[0:1]+b[0:1]+a[1:-1], b[1:]+a[-1:]
@sixthgear
sixthgear / seeker.gridlang
Last active December 10, 2015 21:48
seeker bot
STORE target_x << 0
STORE target_y << 0
STORE move_dir << @NORTH
goto << @main
@main
EQUAL << target_x 0
iffgoto << @main_move
EQUAL << target_y 0
iffgoto << @main_move
STORE counter << 397
STORE direction << @NORTH
@LOOPSTART
CALL << @CHECKS
iftgoto << @LOOPSTART
FFI << @MOVE direction
POP
MINUS << counter 1
STORE counter
@sixthgear
sixthgear / gist:3343998
Created August 13, 2012 20:50
Cash Register Problem

Cash Register Problem

Write a program that calculates the optimal number of coins from a set of given denominations to produce a given amount of currency. The correct answer should be the lowest number of total coins given.

Input

The first line:

k d1 d2 ... dk
@sixthgear
sixthgear / roman.c
Created August 3, 2012 19:48
roman numerals part 2 with restricted symbol set
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
struct symbol_table {
int num;
char sym[3];
};
struct symbol_table symbols[] = {
@sixthgear
sixthgear / roman.c
Created July 24, 2012 23:02
Roman Numerals
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
struct symbol_table {
int num;
char sym[3];
};
struct symbol_table symbols[] = {
#sixthgear, one-up me willya
map = lambda s,f: __builtins__.map(f,s)
# kaptin, safe from desg
def map(source, func):
return __builtins__.map(func, source)
# sixthgear
def mop(source, func):
return map(func, source)
@sixthgear
sixthgear / gist:3128282
Created July 17, 2012 09:19
PQ7 part 2
; roman.s
; x86/BSD
section .text
global start
start:
pop ecx ; argc
cmp ecx, 2 ; make sure we have input
jl argerror
22:28 < greghaynes> Are the happy hacking keyboards worth it?
22:28 < milkshakes> or i will have to unfriend you
22:29 < desg> lmao
00:37 < seabot> meenuh: if a girl hugs me is it okay to ask her if she wants to have sex
00:37 < AeroNotix> seabot: Perfectly acceptable
00:37 < desg> lmao
17:57 < Distilled> LOL
17:58 < Distilled> Patch notes: Prevent motherboard from catching fire.