Modal
Model the Box
as a list of integer sizes which can be extracted via regular expression.
If you are not sure why we build a model (object) first, please check Day 0 and you can find out how to get a list of models from string (or file) as well.
Part 1
Given a list of box dimensions in string, find out the total wrapping paper required.
For each line in order to calculate the paper, we outsource it to a function that takes geometric sizes and output wrapping paper .
Part 2
For same list of box dimensions in string, find out the total wrapping paper following another wrapping method.
If you happen to have quite a bit different wrapping method, it might be worthwhile to come up a function that accepts the wrapping method as one of the input variables.
Highlights
- How to extract info using regular expression?
- How to swap a method with another method?
Now, ready for the next day? Day 3 — Perfectly Spherical Houses in a Vaccum
Or, revisit the previous day? Day 1 — Not Quite Lisp
For Complete source code, please visit AoC 2015 Kotlin.