Skip to content

Instantly share code, notes, and snippets.

View sixthgear's full-sized avatar

Joshua Cender sixthgear

View GitHub Profile
def check_word(word, letters):
"""
Check if a specific word can be created from the set of letters.
"""
for w in word:
pos = letters.find(w)
if pos == -1:
return False
letters = letters[:pos] + letters[pos+1:]
return True
@sixthgear
sixthgear / gist:1299556
Created October 19, 2011 20:24
land.sketch
private static class WorldSnapShot
{
// Height of world
float[][] world;
// Height of water
float[][] water;
// Height of snow.
float[][] snow;
@sixthgear
sixthgear / interp.c
Created October 19, 2011 03:45
Command table from gz2
/*
* Command table.
*/
const struct cmd_type cmd_table[] = {
/*
* Common movement commands.
*/
{"north", do_north, POS_STANDING, 0, LOG_NEVER, 1, 1, 0, 1},
{"east", do_east, POS_STANDING, 0, LOG_NEVER, 1, 1, 0, 1},
{"south", do_south, POS_STANDING, 0, LOG_NEVER, 1, 1, 0, 1},
/*
** float q_rsqrt( float number )
*/
float Q_rsqrt( float number )
{
floatint_t t;
float x2, y;
const float threehalfs = 1.5F;
x2 = number * 0.5F;
/*
================
Q_isnan
Don't pass doubles to this
================
*/
int Q_isnan( float x )
{
floatint_t fi;
import math
from collections import defaultdict
def hierarchize(flatlist, func):
output = defaultdict(list)
for item in flatlist:
output[func(item)].append(item)
return output.values()
def evens(n):
int width = 600;
int height = 600;
int total_points = 100000;
int point_size = 1;
float point_spacing = 1.0;
boolean isPrime(int n) {
if (n < 2) return false;
else if (n == 2) return true;
else if (n % 2 == 0) return false;
@sixthgear
sixthgear / encaps.js
Created August 11, 2011 21:58
Javascript Encapsulation
var obj = function(s) {
// private member
v1 = "priv: " + s;
// public member
this.v2 = "pub: " + s;
// private methods can access private members
function m1() {
@sixthgear
sixthgear / file.js
Created August 10, 2011 03:16 — forked from anonymous/file.js
/*Using JQuery to pull files from italy.xml*/
$(document).ready(function() {
$.ajax({
type: "GET",
url: "xml/italy.xml",
dataType: "xml",
success: handleResponse
});
}); //end ready
/* sixthgear's horrible inplace reverse */
#include <stdio.h>
int
main()
{
int i;
int l = 9;
int a[] = {1,2,3,4,5,6,7,8,9};