Day 2 solution.
This commit is contained in:
@@ -8,15 +8,12 @@
|
||||
* Runtime: ~0.158ms
|
||||
*/
|
||||
function day1solution1() {
|
||||
$start_time = microtime(true);
|
||||
$instructions = file_get_contents('./2015/inputs/day1.txt');
|
||||
$up_floors = substr_count($instructions, "(");
|
||||
$down_floors = substr_count($instructions, ")");
|
||||
$total = $up_floors - $down_floors;
|
||||
echo "The answer is $total\n";
|
||||
$end_time = microtime(true);
|
||||
$execution_time = ($end_time - $start_time);
|
||||
echo $execution_time * 1000 . "\n";
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -25,7 +22,6 @@ function day1solution1() {
|
||||
* Runtime: ~.33ms
|
||||
*/
|
||||
function day1solution1b() {
|
||||
$start_time = microtime(true);
|
||||
$instructions = file_get_contents('./2015/inputs/day1.txt');
|
||||
$chars = str_split($instructions);
|
||||
$position = 1;
|
||||
@@ -42,8 +38,6 @@ function day1solution1b() {
|
||||
$position++;
|
||||
}
|
||||
};
|
||||
echo "The position is $position\n";
|
||||
$end_time = microtime(true);
|
||||
$execution_time = ($end_time - $start_time);
|
||||
echo $execution_time * 1000 . "\n";
|
||||
|
||||
return $position;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user