Skip to content

Instantly share code, notes, and snippets.

View CT075's full-sized avatar

Cameron Wong CT075

View GitHub Profile
/*
* FE Editor - GBA Fire Emblem (U) ROM editor
*
* Copyright (C) 2008-2011 Hextator,
* hextator (AIM) hextator@gmail.com (MSN)
*
* Major thanks to Zahlman (AIM/MSN: zahlman@gmail.com) for optimization,
* organization and modularity improvements.
*
* This program is free software; you can redistribute it and/or modify
/*
* FE Editor - GBA Fire Emblem (U) ROM editor
*
* Copyright (C) 2008-2011 Hextator,
* hextator (AIM) hextator@gmail.com (MSN)
*
* Major thanks to Zahlman (AIM/MSN: zahlman@gmail.com) for optimization,
* organization and modularity improvements.
*
* This program is free software; you can redistribute it and/or modify
/*
* FE Editor - GBA Fire Emblem (U) ROM editor
*
* Copyright (C) 2008-2011 Hextator,
* hextator (AIM) hextator@gmail.com (MSN)
*
* Major thanks to Zahlman (AIM/MSN: zahlman@gmail.com) for optimization,
* organization and modularity improvements.
*
* This program is free software; you can redistribute it and/or modify
public String ASCIIToUnicode(byte[] data)
{
String output = "";
for (int i = 0; i < data.length; i++)
{
switch (data[i])
{
case 0:
output += "[X]";
-- Author: CT075
import Data.List
import Data.Maybe
dictGet :: (Eq k) => k -> [(k,v)] -> Maybe v
dictGet key = foldr (\(k,v) acc -> if key == k then Just v else acc) Nothing
resolveLink :: [Char] -> [([Char], [Char])] -> [Char]
resolveLink ln links = foldl (\acc (x, y) -> replacePrefix acc x y) ln links
@CT075
CT075 / symlinks.hs
Last active August 29, 2015 14:12
DailyProgrammer Challenge 12/28/2014
@CT075
CT075 / mathdice.py
Created January 1, 2015 09:03
DailyProgrammer Challenge 2014/12/31
#!usr/bin/python
# Written by CT075
import functools, random
# TODO: Make a dynamic programming solution
# The reason I cast between tuple and list is so the lru cache doesn't
# complain about lists being an "unhashable type"
@functools.lru_cache(maxsize=64)
def find_soln(targ, nums, cache={}):
@CT075
CT075 / TriangleWords.rkt
Created January 1, 2015 22:55
Project Euler #42 Solution
#lang racket
(define (is-triangular n)
(let ([q (+ 1 (* 8 n))])
(eqv? (integer-sqrt q) (sqrt q))))
(define (encode-string str)
(encode-charlist (string->list str)))
(define (encode-charlist clist)
@CT075
CT075 / TotientQuotient.py
Created January 2, 2015 05:12
Project Euler #69 Solution
# Written by CT075
from operator import mul
from functools import reduce, lru_cache
from math import sqrt, ceil
@lru_cache(maxsize=64)
def prime_factors(n):
for i in range(2, ceil(sqrt(n))+1):
if n % i == 0: return [i] + prime_factors(n/i)
@CT075
CT075 / MatrixPaths1.py
Created January 3, 2015 02:45
Project Euler #81 Solution
# Written by CT075
import json
# Turn the string read from matrix.txt into a 2d list
def process_matrix(data):
data = '[[' + data
data = data.replace('\n', '],[')
data = data[:-2] + ']'
return json.loads(data)