6th day 1st part
This commit is contained in:
1
06/input
Normal file
1
06/input
Normal file
@@ -0,0 +1 @@
|
||||
1,3,4,1,1,1,1,1,1,1,1,2,2,1,4,2,4,1,1,1,1,1,5,4,1,1,2,1,1,1,1,4,1,1,1,4,4,1,1,1,1,1,1,1,2,4,1,3,1,1,2,1,2,1,1,4,1,1,1,4,3,1,3,1,5,1,1,3,4,1,1,1,3,1,1,1,1,1,1,1,1,1,1,1,1,1,5,2,5,5,3,2,1,5,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,5,1,1,1,1,5,1,1,1,1,1,4,1,1,1,1,1,3,1,1,1,1,1,1,1,1,1,1,1,3,1,2,4,1,5,5,1,1,5,3,4,4,4,1,1,1,2,1,1,1,1,1,1,2,1,1,1,1,1,1,5,3,1,4,1,1,2,2,1,2,2,5,1,1,1,2,1,1,1,1,3,4,5,1,2,1,1,1,1,1,5,2,1,1,1,1,1,1,5,1,1,1,1,1,1,1,5,1,4,1,5,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,5,4,5,1,1,1,1,1,1,1,5,1,1,3,1,1,1,3,1,4,2,1,5,1,3,5,5,2,1,3,1,1,1,1,1,3,1,3,1,1,2,4,3,1,4,2,2,1,1,1,1,1,1,1,5,2,1,1,1,2
|
||||
19
06/part1.php
Normal file
19
06/part1.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
$input = file('input', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||
$input = explode(',', $input[0]);
|
||||
|
||||
$fishes = array_fill(0, 9, 0);
|
||||
foreach ($input as $fish) {
|
||||
$fishes[$fish]++;
|
||||
}
|
||||
|
||||
for ($i = 1; $i <= 80; $i++) {
|
||||
$newLanternFish = $fishes[0];
|
||||
for ($j = 1; $j <= 8; $j++) {
|
||||
$fishes[$j-1] = $fishes[$j];
|
||||
}
|
||||
$fishes[6] += $newLanternFish;
|
||||
$fishes[8] = $newLanternFish;
|
||||
}
|
||||
echo array_sum($fishes); //390011
|
||||
Reference in New Issue
Block a user