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

1000
02/input Normal file

File diff suppressed because it is too large Load Diff

1
02/input2 Normal file
View File

@ -0,0 +1 @@
2x3x4

30
02/part1.py Normal file
View File

@ -0,0 +1,30 @@
#!/usr/bin/python
import re
def read_file(filename):
file = open(filename, 'r')
while True:
line = file.readline()
if not line:
break
yield line
def main():
size = 0
for line in read_file('input'):
match = re.match(r'(\d+)x(\d+)x(\d+)', line)
s1 = int(match.group(1))*int(match.group(2))
s2 = int(match.group(1))*int(match.group(3))
s3 = int(match.group(2))*int(match.group(3))
size = size + 2*s1 + 2*s2 + 2*s3 + min(s1, s2, s3)
print size
if __name__ == "__main__":
main()

30
02/part2.py Normal file
View File

@ -0,0 +1,30 @@
#!/usr/bin/python
import re
def read_file(filename):
file = open(filename, 'r')
while True:
line = file.readline()
if not line:
break
yield line
def main():
length = 0
for line in read_file('input'):
match = re.match(r'(\d+)x(\d+)x(\d+)', line)
l1 = int(match.group(1))
l2 = int(match.group(2))
l3 = int(match.group(3))
length= length + 2*min(l1+l2, l1+l3, l2+l3) + l1*l2*l3
print length
if __name__ == "__main__":
main()