d1 + d2/2
This commit is contained in:
		
							
								
								
									
										1000
									
								
								2015/d2/input
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1000
									
								
								2015/d2/input
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										15
									
								
								2015/d2/main.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								2015/d2/main.py
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,15 @@ | ||||
| import re | ||||
|  | ||||
| def get_dimentions(inp: str) -> tuple: | ||||
|     result = re.match("(\d+)x(\d+)x(\d+)",inp) | ||||
|     return tuple(map(int, result.groups())) | ||||
|  | ||||
| def get_wrap(inp: tuple) -> int: | ||||
|     return 2 * inp[0] * inp[1] + 2 * inp[1] * inp[2] + 2 * inp[2] * inp[0] + min(inp[0] * inp[1], inp[1] * inp[2], inp[2] * inp[0]) | ||||
|  | ||||
| with open("input", "r") as f: | ||||
|     presents = map(get_dimentions, map(str.strip, f.readlines())) | ||||
|     wrap_for_each = map(get_wrap, presents) | ||||
|     print(sum(wrap_for_each)) | ||||
|  | ||||
| # TODO: Missing part two | ||||
		Reference in New Issue
	
	Block a user