Last active
December 3, 2015 21:22
-
-
Save kragniz/942f4b930154bafbae7d to your computer and use it in GitHub Desktop.
adventofcode
This file contains 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 python3 | |
s = input() | |
t = 0 | |
for i, c in enumerate(s): | |
if c == '(': t += 1 | |
elif c == ')': t += -1 | |
if t == -1: print i; break |
This file contains 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 python3 | |
print(sum([2*l*w + 2*w*h + 2*h*l + l*w | |
for l, w, h in | |
[sorted([int(i) for i in s.split('x')]) | |
for s in __import__('sys').stdin.readlines()]])) |
This file contains 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 python3 | |
print(sum([2*l + 2*w + l*w*h | |
for l, w, h in | |
[sorted([int(i) for i in s.split('x')]) | |
for s in __import__('sys').stdin.readlines()]])) |
This file contains 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 python3 | |
l = ['0,0'] | |
x, y = 0, 0 | |
for c in input(): | |
if c == '>': x += 1 | |
if c == '<': x -= 1 | |
if c == '^': y += 1 | |
if c == 'v': y -= 1 | |
l += ['%d,%d' % (x, y)] | |
print(len(set(l))) |
This file contains 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 python3 | |
# got lazy with this one | |
l = ['0,0'] | |
x, y = 0, 0 | |
d = input() | |
for c in d[::2]: | |
if c == '>': x += 1 | |
if c == '<': x -= 1 | |
if c == '^': y += 1 | |
if c == 'v': y -= 1 | |
l += ['%d,%d' % (x, y)] | |
x, y = 0, 0 | |
for c in d[1::2]: | |
if c == '>': x += 1 | |
if c == '<': x -= 1 | |
if c == '^': y += 1 | |
if c == 'v': y -= 1 | |
l += ['%d,%d' % (x, y)] | |
print(len(set(l))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment