Day 6 in php, this was a mistake lol
This commit is contained in:
parent
d2346af0da
commit
c30135ef6a
1
2021/6/.gitignore
vendored
Normal file
1
2021/6/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
input
|
28
2021/6/growth.php
Normal file
28
2021/6/growth.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#!/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);
|
||||||
|
|
||||||
|
?>
|
Loading…
x
Reference in New Issue
Block a user