first commit

This commit is contained in:
Peter Hudec
2015-12-17 01:55:50 +01:00
commit 6a4482d038
35 changed files with 3965 additions and 0 deletions

1
01/input Normal file

File diff suppressed because one or more lines are too long

23
01/part1.py Normal file
View File

@ -0,0 +1,23 @@
#!/usr/bin/python
def read_file(filename, chunk=1024):
file = open(filename, 'r')
while True:
line = file.read(chunk)
if not line:
break
yield line
def main():
floor = 0
for line in read_file('input'):
up = line.count('(')
down = line.count(')')
floor = floor + up - down
print floor
if __name__ == "__main__":
main()

27
01/part2.py Normal file
View File

@ -0,0 +1,27 @@
#!/usr/bin/python
def read_file(filename, chunk=1024):
file = open(filename, 'r')
while True:
line = file.read(chunk)
if not line:
break
yield line
def main():
floor = 0
pos = 1
for line in read_file('input', 1):
up = line.count('(')
down = line.count(')')
floor = floor + up - down
if floor == -1:
break
pos = pos + 1
print pos
if __name__ == "__main__":
main()