Skip to content

Instantly share code, notes, and snippets.

Ross Andrews randrews

Block or report user

Report or block randrews

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View lcd.bas
Dim control_port As Short
control_port = 0x80 'Reset high, everything else low
Put 2, control_port
Dim io_mode As Short
io_mode = 0b10000010 'Ports A and C (both halves) output, B input
Dim lcd_input As Boolean
lcd_input = True 'Ignore this
Call setlcdinput(False)
View calc.js
const next = (n) => [
(n * 10) + 1,
n + 12,
n * 13,
Math.floor(n / 10),
parseInt(n.toString().split('').reverse().join(''), 10)
];
const open = [0];
const goal = 196;
View main.c
void init_lcd();
void set_xy(char row, char col, char chip);
void draw_sprite(const char const *sprite, char chip);
void asm_helpers();
const char CS2 = 0x10;
const char CS1 = 0x08;
const char arrow[8] = {
0b00010000,
0b00100000,
View day10.py
import re
class Bot:
def __init__(self, group, low, high):
self._queue = []
self._low_target = low
self._high_target = high
self._group = group
View day9.py
import re
from functools import *
def read_file(filename):
with open(filename) as f:
return f.readline()
def decompressed_string(str, version=1):
View day8.py
import io, re
def read_instructions(filename):
file = io.open(filename)
rect_pat = re.compile('rect (\d+)x(\d+)')
row_pat = re.compile('rotate row y=(\d+) by (\d+)')
col_pat = re.compile('rotate column x=(\d+) by (\d+)')
instructions = []
View day21.rb
def flipx(arr)
arr.map(&:dup).reverse
end
def flipy(arr)
arr.map(&:reverse)
end
View day20.rb
class Particle
attr_reader :num
def initialize(line, num)
@num = num
if line =~ /p=<(.*?),(.*?),(.*?)>, v=<(.*?),(.*?),(.*?)>, a=<(.*?),(.*?),(.*?)>/
@px=$1.to_i
@py=$2.to_i
@pz=$3.to_i
View day13.rb
layers = {}
File.open('day13.txt') do |f|
f.each do |line|
if line =~ /(\d+): (\d+)/
depth, range = $1.to_i, $2.to_i
layers[depth] = range
end
end
end
View day12.rb
pipes = {}
File.open('day12.txt') do |f|
f.each do |line|
if line =~ /(\d+) <-> (.*)/
prog1 = $1.to_i
$2.split(', ').map(&:to_i).each do |prog2|
pipes[prog1] ||= []
pipes[prog2] ||= []
pipes[prog1] << prog2
pipes[prog2] << prog1
You can’t perform that action at this time.