29 lines
504 B
PHP
29 lines
504 B
PHP
#!/usr/bin/env php
|
|
<?php
|
|
|
|
// This is very hacky
|
|
ini_set('memory_limit', '-1');
|
|
|
|
$input = file_get_contents("input");
|
|
$input = explode(",", $input);
|
|
|
|
$days = 256;
|
|
|
|
for($day=0; $day<$days; $day++){
|
|
|
|
echo "\rAt day $day/$days. ".count($input)." lanternfish currently. Memory usage: " . floor(memory_get_peak_usage() / 1024 / 1024) . "MiB.";
|
|
|
|
foreach($input as $i => &$v) {
|
|
$v--;
|
|
if($v == -1) {
|
|
$v = 6;
|
|
$input[] = 9;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
echo "Total number of fish after $days days: " . count($input);
|
|
|
|
?>
|