This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <array> | |
| #include <iostream> | |
| #include <queue> | |
| enum direction { n = 0, s = 1, e = 2, w = 3 }; | |
| enum state { red = 0, yellow = 1, red_n = 2, red_s = 3, red_e = 4, red_w = 5 }; | |
| constexpr std::array<int, 4> dx = {0, 0, 1, -1}; | |
| constexpr std::array<int, 4> dy = {-1, 1, 0, 0}; | |
| constexpr std::array<char, 4> dc = {'^', 'v', '>', '<'}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import re | |
| import cmath | |
| import math | |
| with open('24.txt') as f: | |
| a = f.read()[:-1] | |
| lines = a.split('\n') | |
| directions = [1, -1, 1j, -1j, -1 + 1j, 1 - 1j] | |
| repl = [('ne', 2), ('nw', 4), ('sw', 3), ('se', 5), ('e', 0), ('w', 1)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn main() { | |
| const MAX: usize = 1_000_000usize; | |
| let input = [1, 2, 3, 4, 8, 7, 5, 9, 6]; | |
| let nodes = input.iter().map(|i| i - 1).chain(9..MAX); | |
| let mut nex = [0usize; MAX]; | |
| let mut last: usize = MAX - 1; | |
| for i in nodes { | |
| nex[last] = i; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import re | |
| import cmath | |
| import math | |
| with open('21s.txt') as f: | |
| a = f.read()[:-1].split('\n') | |
| asdf = {} | |
| often = {} | |
| for line in a: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import re | |
| import cmath | |
| import math | |
| import cv2 | |
| import numpy as np | |
| import time | |
| def edges(v): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import re | |
| import cmath | |
| import math | |
| def edges(v): | |
| return [ | |
| v[0], ''.join(vv[-1] for vv in v), | |
| rev((v[-1])), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import re | |
| import cmath | |
| import math | |
| def wat(x): | |
| while '+' in x: | |
| m = re.search(r'(\d+ \+ \d+)', x) | |
| s = m.group() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import re | |
| import cmath | |
| import math | |
| with open('16s.txt') as f: | |
| a = f.read()[:-1] | |
| defs, yourneigh = a.split('\n\nyour ticket:\n') | |
| your, neigh = yourneigh.split('\n\nnearby tickets:\n') | |
| va = {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import re | |
| import cmath | |
| import math | |
| mem = {} | |
| def asdf(mask, v, val): | |
| global mem |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import re | |
| import cmath | |
| import math | |
| def gcd(a, b): | |
| if a == 0: | |
| return b | |
| if b == 0: |
NewerOlder