You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

21 lines
562 B

<?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));