| Total Complexity | 11 |
| Total Lines | 69 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class Day1 implements Day |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * @var array |
||
| 11 | */ |
||
| 12 | private array $changes; |
||
| 13 | |||
| 14 | public function loadInput(): void |
||
| 15 | { |
||
| 16 | $file = fopen(__DIR__ . '/input/day-1.txt', "r"); |
||
| 17 | while (!feof($file)) { |
||
|
|
|||
| 18 | $this->changes[] = intval(fgets($file)); |
||
| 19 | } |
||
| 20 | fclose($file); |
||
| 21 | } |
||
| 22 | |||
| 23 | public function solve() |
||
| 24 | { |
||
| 25 | $result = $this->calculateFrequency(); |
||
| 26 | |||
| 27 | printf('The resulting frequency is: %s', $result); |
||
| 28 | } |
||
| 29 | |||
| 30 | public function setChanges(array $changes): void |
||
| 31 | { |
||
| 32 | $this->changes = $changes; |
||
| 33 | } |
||
| 34 | |||
| 35 | public function getChanges(): array |
||
| 36 | { |
||
| 37 | return $this->changes; |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @param int $frequency -> The starting frequency |
||
| 42 | * @return int |
||
| 43 | */ |
||
| 44 | public function calculateFrequency(int $frequency = 0): int |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @param int $frequency -> The starting frequency |
||
| 55 | * @return int |
||
| 56 | */ |
||
| 57 | public function getFrequencyReachedTwice(int $frequency = 0): int |
||
| 76 | } |
||
| 77 | } |
||
| 78 |