Skip to content

Instantly share code, notes, and snippets.

@kragniz
Last active December 3, 2015 21:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kragniz/942f4b930154bafbae7d to your computer and use it in GitHub Desktop.
Save kragniz/942f4b930154bafbae7d to your computer and use it in GitHub Desktop.
adventofcode
#!/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
#!/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()]]))
#!/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()]]))
#!/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)))
#!/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