0
0
Fork 0

Add code for 2015 advent that I did historically.

This commit is contained in:
Oliver-Akins 2020-12-06 20:33:17 -07:00
parent 13968ed94e
commit 9e9e556c73
25 changed files with 598 additions and 0 deletions

29
day_2/part_2.ts Normal file
View file

@ -0,0 +1,29 @@
// @ts-ignore
import { readFileSync } from "fs";
let data: string = readFileSync("input", "utf-8");
let ribbon_sum: number = 0;
for (var line of data.split(`\n`)) {
let dimensions: string[] = line.split("x", 3);
let l = parseInt(dimensions[0]);
let w = parseInt(dimensions[1]);
let h = parseInt(dimensions[2]);
let min_perimeter: number = Math.min(
l+l+w+w,
l+l+h+h,
w+w+h+h
);
let volume: number = l * w * h;
ribbon_sum = ribbon_sum + min_perimeter + volume;
};
console.log(`Ribbon Length Needed: ${ribbon_sum}`);