Advertisement
Guest User

Untitled

a guest
Dec 6th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.45 KB | None | 0 0
  1. <?php
  2. for ($mem = array_map('intval', explode("\t", trim(file_get_contents('input.txt')))), $hist = []; count($hist) == count(array_unique($hist)); $hist[] = implode("-", $mem)) {
  3.     for ($mem[$i = array_search($blocks = max($mem), $mem)] = 0; $blocks > 0; $blocks--) {
  4.         $mem[(++$i) % count($mem)]++;
  5.     }
  6. }
  7. echo "Part One: " . count($hist) . PHP_EOL . "Part Two: " . (count($hist) - 1 - array_search($hist[count($hist) - 1], $hist)) . PHP_EOL;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement