Skip to content

Instantly share code, notes, and snippets.

View sixthgear's full-sized avatar

Joshua Cender sixthgear

View GitHub Profile
#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 / 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
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 / 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
STORE counter << 397
STORE direction << @NORTH
@LOOPSTART
CALL << @CHECKS
iftgoto << @LOOPSTART
FFI << @MOVE direction
POP
MINUS << counter 1
STORE counter
@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
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 / 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
package main
import "math"
import "github.com/sixthgear/noise"
import "github.com/go-gl/gl"
type Vertex struct {
x, y, z float32
}
@sixthgear
sixthgear / gist:6943074
Last active December 25, 2015 07:59
##proggit Five Day Gamejelly

FIVE DAY GAMEJELLY

WTF?

Write an original game in at most five working days. The gamejam will run for a month, so feel free to spread out those 5 days as you see fit. When you are finished, reply to this gist with a link to your public source code repository, and optionally binary downloads or playable web links.