Skip to content

Commit 881f01e

Browse files
committed
Day 2 and Day 3
0 parents  commit 881f01e

11 files changed

+1257
-0
lines changed

.gitignore

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Source:
2+
# https://github.com/github/gitignore/blob/master/Ruby.gitignore
3+
4+
# Additions
5+
.DS_Store
6+
7+
*.gem
8+
*.rbc
9+
/.config
10+
/coverage/
11+
/InstalledFiles
12+
/pkg/
13+
/spec/reports/
14+
/test/tmp/
15+
/test/version_tmp/
16+
/tmp/
17+
18+
## Specific to RubyMotion:
19+
.dat*
20+
.repl_history
21+
build/
22+
23+
## Documentation cache and generated files:
24+
/.yardoc/
25+
/_yardoc/
26+
/doc/
27+
/rdoc/
28+
29+
## Environment normalisation:
30+
/.bundle/
31+
/vendor/bundle
32+
/lib/bundler/man/
33+
34+
# for a library or gem, you might want to ignore these files since the code is
35+
# intended to run in multiple environments; otherwise, check them in:
36+
Gemfile.lock
37+
.ruby-version
38+
.ruby-gemset
39+
40+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
41+
.rvmrc

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Gordon Chan
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Advent of Code Solutions
2+
3+
[My](https://github.com/gchan/) solutions to the programming puzzles on [Advent of Code](http://adventofcode.com/).
4+
5+
Solutions are written in [Ruby](https://www.ruby-lang.org/en/).
6+
7+
_"Advent of Code is a series of small programming puzzles for a variety of skill levels. They are self-contained and are just as appropriate for an expert who wants to stay sharp as they are for a beginner who is just learning to code. Each puzzle calls upon different skills and has two parts that build on a theme."_
8+
9+
### License
10+
11+
MIT
12+
13+
[![Analytics](https://ga-beacon.appspot.com/UA-70790190-2/advent_of_code_ruby/README.md?flat)](https://github.com/igrigorik/ga-beacon)

day-2/README.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
## Day 2: I Was Told There Would Be No Math
2+
3+
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.
4+
5+
Fortunately, every present is a box (a perfect right rectangular prism), 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.
6+
7+
For example:
8+
9+
* 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.
10+
* 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.
11+
12+
All numbers in the elves' list are in feet. How many total square feet of wrapping paper should they order?
13+
14+
### Part Two
15+
16+
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.
17+
18+
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.
19+
20+
For example:
21+
22+
* 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.
23+
* 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.
24+
25+
How many total feet of ribbon should they order?

0 commit comments

Comments
 (0)