Skip to content

Instantly share code, notes, and snippets.

View theglauber's full-sized avatar

Glauber Ribeiro theglauber

View GitHub Profile
@theglauber
theglauber / day9.py
Last active December 11, 2019 15:08
Advent of code 2019 day 9
#!python
"""
https://adventofcode.com/2019/day/9
This starts again with the interpreter from day 5.
This runs both of the day 9 problems (after running the test data).
First:
@theglauber
theglauber / day8a.py
Created December 9, 2019 09:43
Advent of code 2019 day 8
#! python
"""
https://adventofcode.com/2019/day/8
"""
def chunker(seq, size):
return (seq[pos:pos + size] for pos in range(0, len(seq), size))
@theglauber
theglauber / day7-data.txt
Created December 9, 2019 08:27
Advent of code 2019 day 7
test1:3,15,3,16,1002,16,10,16,1,16,15,15,4,15,99,0,0
test2:3,23,3,24,1002,24,10,24,1002,23,-1,23,101,5,23,23,1,24,23,23,4,23,99,0,0
test3:3,31,3,32,1002,32,10,32,1001,31,-2,31,1007,31,0,33,1002,33,7,33,1,33,31,31,1,32,31,31,4,31,99,0,0,0
test1b:3,26,1001,26,-4,26,3,27,1002,27,2,27,1,27,26,27,4,27,1001,28,-1,28,1005,28,6,99,0,0,5
test2b:3,52,1001,52,-5,52,3,53,1,52,56,54,1007,54,5,55,1005,55,26,1001,54,-5,54,1105,1,12,1,53,54,53,1008,54,0,55,1001,55,1,55,2,53,55,53,4,53,1001,56,-1,56,1005,56,6,99,0,0,0,0,10
data:3,8,1001,8,10,8,105,1,0,0,21,38,55,72,93,118,199,280,361,442,99999,3,9,1001,9,2,9,1002,9,5,9,101,4,9,9,4,9,99,3,9,1002,9,3,9,1001,9,5,9,1002,9,4,9,4,9,99,3,9,101,4,9,9,1002,9,3,9,1001,9,4,9,4,9,99,3,9,1002,9,4,9,1001,9,4,9,102,5,9,9,1001,9,4,9,4,9,99,3,9,101,3,9,9,1002,9,3,9,1001,9,3,9,102,5,9,9,101,4,9,9,4,9,99,3,9,101,1,9,9,4,9,3,9,1001,9,1,9,4,9,3,9,102,2,9,9,4,9,3,9,101,2,9,9,4,9,3,9,1001,9,1,9,4,9,3,9,102,2,9,9,4,9,3,9,1001,9,1,9,4,9,3,9,102,2,9,9,4,9,3,9,102,2,9,9,4,9,3,9,1002,9,2,9,4,9,99,3,9,10
@theglauber
theglauber / day6-data.txt
Created December 7, 2019 02:42
Advent of code 2019 day 6
YQ2)CYG
63M)X4N
7YF)LRN
K2B)PVC
394)195
W68)QNR
XDS)SX7
JWG)789
6RR)4R1
S9Y)M1X
@theglauber
theglauber / day5a.py
Last active December 6, 2019 02:52
Advent of code 2019 day 5
#!python
"""
https://adventofcode.com/2019/day/5
Opcodes:
-------
::
@theglauber
theglauber / day4a.py
Created December 4, 2019 06:14
Advent of code 2019 day 4
#! python
# https://adventofcode.com/2019/day/4
min = 265275
max = 781584
counter = 0
def check_pw(n):
"""
@theglauber
theglauber / day3a.py
Created December 3, 2019 14:11
Advent of code 2019 day 3
#! python
# https://adventofcode.com/2019/day/3
"""
Find intersection that's closest to source
------------------------------------------
We use sets of tuples to store the path of each 'wire',
so we can use set intersection to find where they cross.
"""
@theglauber
theglauber / day2a.py
Created December 3, 2019 06:53
Advent of code 2019 day 2
#!python
program = [ 1,0,0,3,1,1,2,3,1,3,4,3,1,5,0,3,2,13,1,19,1,19,10,23,2,10,23,27,1,27,6,31,1,13,31,35,1,13,35,39,1,39,10,43,2,43,13,47,1,47,9,51,2,51,13,55,1,5,55,59,2,59,9,63,1,13,63,67,2,13,67,71,1,71,5,75,2,75,13,79,1,79,6,83,1,83,5,87,2,87,6,91,1,5,91,95,1,95,13,99,2,99,6,103,1,5,103,107,1,107,9,111,2,6,111,115,1,5,115,119,1,119,2,123,1,6,123,0,99,2,14,0,0 ]
def chunker(seq, size):
return (seq[pos:pos + size] for pos in range(0, len(seq), size))
# restore the "1202 error"
@theglauber
theglauber / adv01.pl
Last active December 1, 2019 23:03
20191201 Advent of Code 2019 day 1
#!/bin/perl
use strict;
use integer;
sub fuel {
my $mass = $_[0] + 0;
my $fuel = $mass / 3 - 2;
return $fuel;
}

Keybase proof

I hereby claim:

  • I am theglauber on github.
  • I am theglauber (https://keybase.io/theglauber) on keybase.
  • I have a public key whose fingerprint is C729 E690 1FE6 A6F1 6BCD 34AB 7318 BFCA 6EF0 9914

To claim this, I am signing this object: