Skip to content

Commit

Permalink
added 2015 day2 typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexAegis committed Jun 9, 2019
1 parent e3ec38a commit 44f6d28
Show file tree
Hide file tree
Showing 10 changed files with 1,124 additions and 5 deletions.
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
| -------------------------- | ------------------------------------------------ | ----------------------------------------- | -------------------------------------------------- | ----------------------------------------- |
| | TypeScript | Rust | TypeScript | Rust |
| [Day 1](./src/2015/day01/) | [0.5ms](./src/2015/day01/typescript/part_one.ts) | [6.2μs](./src/2015/day01/rust/src/lib.rs) | [ 1.2ms ](./src/2015/day01/typescript/part_two.ts) | [1.9μs](./src/2015/day01/rust/src/lib.rs) |
| Day 2 | | | | |
| [Day 2](./src/2015/day02/) | [2ms](./src/2015/day02/typescript/part_one.ts) | | [2.4ms](./src/2015/day02/typescript/part_two.ts) | |
| Day 3 | | | | |
| Day 4 | | | | |
| Day 5 | | | | |
Expand Down
33 changes: 33 additions & 0 deletions src/2015/day02/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# [Day 2: I Was Told There Would Be No Math](https://adventofcode.com/2015/day/2)

## [Part One](https://adventofcode.com/2015/day/2#part1) - [TypeScript](./typescript/part_one.ts)

The elves are running low on wrapping paper, and so they need to submit an order for more. They have a list of the dimensions (length `l`, width `w`, and height `h`) of each present, and only want to order exactly as much as they need.

Fortunately, every present is a box (a perfect [right rectangular prism](https://en.wikipedia.org/wiki/Cuboid#Rectangular_cuboid)), which makes calculating the required wrapping paper for each gift a little easier: find the surface area of the box, which is `2*l*w + 2*w*h + 2*h*l`. The elves also need a little extra paper for each present: the area of the smallest side.

For example:

- A present with dimensions `2x3x4` requires `2*6 + 2*12 + 2*8 = 52` square feet of wrapping paper plus `6` square feet of slack, for a total of `58` square feet.
- A present with dimensions `1x1x10` requires `2*1 + 2*10 + 2*10 = 42` square feet of wrapping paper plus `1` square foot of slack, for a total of `43` square feet.

All numbers in the elves' list are in feet. How many total **square feet of wrapping paper** should they order?

Your puzzle answer was `1606483`.

The first half of this puzzle is complete! It provides one gold star: \*

## [Part Two](https://adventofcode.com/2015/day/2#part2) - [TypeScript](./typescript/part_two.ts)

The elves are also running low on ribbon. Ribbon is all the same width, so they only have to worry about the length they need to order, which they would again like to be exact.

The ribbon required to wrap a present is the shortest distance around its sides, or the smallest perimeter of any one face. Each present also requires a bow made out of ribbon as well; the feet of ribbon required for the perfect bow is equal to the cubic feet of volume of the present. Don't ask how they tie the bow, though; they'll never tell.

For example:

- A present with dimensions `2x3x4` requires `2+2+3+3 = 10` feet of ribbon to wrap the present plus `2*3*4 = 24` feet of ribbon for the bow, for a total of `34` feet.
- A present with dimensions `1x1x10` requires `1+1+1+1 = 4` feet of ribbon to wrap the present plus `1*1*10 = 10` feet of ribbon for the bow, for a total of `14` feet.

How many total **feet of ribbon** should they order?

Your puzzle answer was `3842356`.

0 comments on commit 44f6d28

Please sign in to comment.