| Total Complexity | 5 |
| Total Lines | 40 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 9 | class Day2 implements Day |
||
| 10 | { |
||
| 11 | /** @var array<string> */ |
||
| 12 | private array $dimensions = []; |
||
| 13 | |||
| 14 | /** @return void */ |
||
| 15 | public function loadInput(): void |
||
| 25 | } |
||
| 26 | |||
| 27 | /** @return void */ |
||
| 28 | public function solve(): void |
||
| 29 | { |
||
| 30 | $amountWrappingPaper = 0; |
||
| 31 | $lengthRibbon = 0; |
||
| 32 | foreach ($this->dimensions as $dimension) { |
||
| 33 | $present = Present::fromString($dimension); |
||
| 34 | $amountWrappingPaper += $present->getSurfaceArea(); |
||
| 35 | $amountWrappingPaper += $present->getSmallestSideArea(); |
||
| 36 | $lengthRibbon += $present->getVolume(); |
||
| 37 | $lengthRibbon += $present->getSmallestSide() * 2; |
||
| 38 | $lengthRibbon += $present->getSecondSmallestSide() * 2; |
||
| 39 | } |
||
| 40 | |||
| 41 | printf("The total amount of wrapping paper is: %s\n", $amountWrappingPaper); |
||
| 42 | printf("The total length of ribbon is: %s\n", $lengthRibbon); |
||
| 43 | } |
||
| 44 | |||
| 45 | /** @return array<string> */ |
||
| 46 | public function getDimensions(): array |
||
| 49 | } |
||
| 50 | } |
||
| 51 |