Browse Source

Day 10 part 1

master
Graeme Dyas 5 months ago
parent
commit
5230f51e67
  1. 28
      Day 10/Part_1.php
  2. 7
      Day 10/Part_2.php
  3. 3
      README.md

28
Day 10/Part_1.php

@ -0,0 +1,28 @@
<?php
$in = file("input.txt");
foreach ($in as &$inv) {
$inv = (int)trim($inv);
}
$ans = array();
sort($in);
$x = 0;
while ($x < count($in)-1) {
array_push($ans,$in[$x + 1] - $in[$x]);
$x++;
}
$ans = array_count_values($ans);
foreach($ans as &$a) {
$a++;
}
$aaa = $ans[1] * $ans[3];
echo $aaa;

7
Day 10/Part_2.php

@ -0,0 +1,7 @@
<?php
$in = file("input.txt");
foreach ($in as &$inv) {
$inv = (int)trim($inv);
}

3
README.md

@ -9,4 +9,5 @@
|6|:heavy_check_mark:|:heavy_check_mark:|
|7|:heavy_check_mark:|:x:|
|8|:heavy_check_mark:|:heavy_check_mark:|
|9|:heavy_check_mark:|:heavy_check_mark:|
|9|:heavy_check_mark:|:heavy_check_mark:|
|10|:heavy_check_mark:|:x:|
Loading…
Cancel
Save