Skip to content

Instantly share code, notes, and snippets.

View erikaderstedt's full-sized avatar

Erik Aderstedt erikaderstedt

View GitHub Profile
@erikaderstedt
erikaderstedt / checkStringsFile.py
Created December 4, 2012 09:03
Check strings files for stupid errors
#!/usr/bin/env python
import sys, codecs, re, os.path
comment = re.compile('/\*.*\*/',re.DOTALL)
regular = re.compile('^\s*"([^"]*)"\s*=\s*"([^"]*)"\s*;\s*$')
if len(sys.argv) < 2:
print "Usage: checkStringsFile.py <filename>"
sys.exit(1)
@erikaderstedt
erikaderstedt / ASGenieKernel.txt
Created July 11, 2016 15:57
Core Image kernel for the Genie effect
//
// ASGenieKernel.cikernel
//
// (c) Aderstedt Software AB 2008.
// Erik Aderstedt 2008-09-05.
//
kernel vec4 ASGenieKernel(sampler src, float t, float D, float ytarget, float scale)
{
// Given a point (destCoord) we are tasked to find its colour.
//
// Genie.swift
// iOrdning7
//
// Created by Erik Aderstedt on 2016-07-11.
// Copyright © 2016 Aderstedt Software AB. All rights reserved.
//
import Cocoa
import Quartz
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ARG0 (modes[0] ? p[i+1] : p[p[i+1]])
#define ARG1 (modes[1] ? p[i+2] : p[p[i+2]])
int run_program(int *program, int length, int input) {
int *p = (int*)calloc(length, sizeof(int));
memcpy(p, program, sizeof(int)*length);
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
int main(int argc, char **argv) {
char digits[7];
size_t pt1 = 0, pt2 = 0, k;
for (uint32_t i = 165432; i <= 707912; i++) {
sprintf(digits, "%u", i);
bool pt1_ok = false, pt2_ok = false;
#!/usr/bin/env python3
# -*- coding: utf8 -*-
import sys
wires = []
for line in open(sys.argv[1],'r').readlines():
parts = line.split(',')
wire = {}
r = 0
3,125,1001,125,-1,125,1101,149,-1,19,1101,0,0,124,1001,19,1,19,1008,0,-1,130,1005,130,121,1001,19,0,65,1001,19,0,71,1105,1,43,1,124,131,124,1105,1,14,1101,0,0,131,1101,0,0,128,1101,0,0,129,1001,129,1,129,1001,128,3,128,7,128,0,130,1005,130,55,8,0,128,130,1005,130,81,1001,129,-1,129,1001,129,-2,129,1007,129,0,130,1006,130,96,1101,0,0,129,1,129,131,131,1006,129,118,1001,129,0,132,1101,132,0,65,1101,132,0,71,1005,125,47,1105,1,36,4,124,99,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,70219,93253,79077,75104,142278,65798,148578,136159,60033,51629,57239,77808,142016,92225,136933,95933,109170,83012,135771,59064,101361,86997,79026,50825,79671,143898,65548,84651,53043,84997,87226,65816,81088,143976,109917,103744,131433,81899,80901,146112,65084,84439,73939,102337,99794,107113,62081,98484,55246,131950,129633,98380,118568,100632,127493,90804,120735,124932,115165,73091,77960,67435,63132,114453,104379,82371,51259,104055,127984,108215,53174,139459,58530,86994,149064,90062,139593,128406,136288,140669,125298,144444,80296
import sys
import re
x = re.compile('(\S+):')
s = open(sys.argv[1],'r').readlines()
s = [x.strip() for x in s]
s = [x for x in s if x[:2] != '//' and x != '']
cmds = []
// Input: 1 - pt 1, 2 - pt 2
3,PROGRAM_MODE
1001,PROGRAM_MODE,-1,PROGRAM_MODE
1101,DATA_START,-1,DATA_INDEX
1101,0,0,TOTAL_MASS
// Get next mass value
NEXT_MASS:
1001,DATA_INDEX,1,DATA_INDEX
// Check if data is -1
#!/usr/bin/env python3
# -*- coding: utf8 -*-
from re import compile
x = compile(r"(\S+)\)(\S+)")
orbits = [x.match(r).groups() for r in open('6.in','r').read().split('\n') if x.match(r) is not None]
def orbit_checker(all_orbits, center, depth):
s = [orbit_checker(all_orbits, j[1], depth+1) for j in [x for x in orbits if x[0] == center]]