Skip to content

Instantly share code, notes, and snippets.

describe('Federation NOMA', () => {
it('has ambition', () => {
expect(federation.creativeWorkspace).toBe('great');
expect(federation.buildings.length).toBeGreaterThan(1);
expect(federation.people.filter((person) => person.cares)).toBeNonEmpty();
expect(federation.wifiSpeedMbps).toEqual(1024);
});
it('can have my people too', () => {
@cnorthwood
cnorthwood / code.py
Created December 25, 2015 20:20
AoC day 25
from itertools import count
def calc(target_x, target_y):
for i in count():
for x in range(1, i):
y = i - x
if (x,y) == (1,1):
code = 20151125
else:
@cnorthwood
cnorthwood / code.py
Created December 24, 2015 11:21
AoC day 24
from operator import mul
INPUT = """1
2
3
5
7
13
17
19
@cnorthwood
cnorthwood / code.py
Created December 23, 2015 13:14
AoC day 22
from collections import namedtuple
from itertools import count
from random import sample
PLAYER_HP = 50
PLAYER_MANA = 500
BOSS_HP = 71
BOSS_DAMAGE = 10
Spell = namedtuple('Spell', ['name', 'cost'])
@cnorthwood
cnorthwood / code.py
Created December 23, 2015 13:10
AoC day 23
registers = {'a': 1, 'b': 0}
def hlf(r):
registers[r] /= 2
return 1
def tpl(r):
registers[r] *= 3
return 1
@cnorthwood
cnorthwood / code.py
Created December 21, 2015 11:30
AoC day 21
from collections import namedtuple
from itertools import chain, combinations, product, ifilterfalse
Item = namedtuple('Item', ['cost', 'damage', 'armour'])
BOSS_HIT_POINTS = 100
BOSS_DAMAGE = 8
BOSS_ARMOUR = 2
INPUT_WEAPONS = """
@cnorthwood
cnorthwood / code.py
Last active December 20, 2015 14:51
AoC day 20
from __future__ import print_function
from itertools import chain, count
from math import sqrt
TARGET = 36000000
factors = lambda i: set(chain.from_iterable((x, i // x) for x in filter(lambda x: i % x == 0, range(1, int(sqrt(i)) + 1))))
part_one = False
@cnorthwood
cnorthwood / code.py
Created December 19, 2015 18:07
AoC day 19
from functools import partial
from itertools import count
import re
INPUT = """Al => ThF
Al => ThRnFAr
B => BCa
B => TiB
B => TiRnFAr
Ca => CaCa
@cnorthwood
cnorthwood / code.py
Created December 18, 2015 11:37
AoC day 18
from collections import defaultdict
from itertools import product
GRID_SIZE = 100
INPUT = """#...##......#......##.##..#...##......##.#.#.###.#.#..#..#......####..#......###.#.#....#..##..###..
####..#.#...#....#.#####.##.##.#..#.......#....#.##...###.###..#.#.#........#..#.#.##...##..#.####.#
...#..##...#.#.###.#.###..#.##.####.###...#...........#.###..##.#.##.#.###...#.#..###....#.###.#..#.
.#...##...####.#..#.....#..#...#.#.##...#...##..#.#.###....#..###.....##..#.###..###.....##..###...#
..##.#####....##..#.#..##.##..######...#..###.######.....#..##...#.#..##..##..#..#..#..##.#.#.#.#...
.###.###.###...##...##..###..##.###.#.....##..##.#.#########...##..##.#..##.#..##..####..#.#.#.#####
@cnorthwood
cnorthwood / code.py
Created December 17, 2015 16:01
AoC day 17
INPUT = """50
44
11
49
42
46
18
32
26
40