✨ Add day 12 part 1
This commit is contained in:
21
day_12/part_1.php
Normal file
21
day_12/part_1.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
include 'Moon.php';
|
||||
include 'Velocity.php';
|
||||
include 'functions.php';
|
||||
|
||||
$moons = array_map(function ($moon) {
|
||||
$moon_coordinates = explode(', ', substr($moon, 1, -1));
|
||||
$x = (int) substr($moon_coordinates[0], 2);
|
||||
$y = (int) substr($moon_coordinates[1], 2);
|
||||
$z = (int) substr($moon_coordinates[2], 2);
|
||||
return new Moon($x, $y, $z);
|
||||
}, explode("\n", file_get_contents('input.txt'))
|
||||
);
|
||||
|
||||
for ($i = 0; $i < 1000; $i++) {
|
||||
calculateVelocity($moons);
|
||||
updateCoordinates($moons);
|
||||
}
|
||||
|
||||
var_dump(calculateEnergy($moons));
|
Reference in New Issue
Block a user