Skip to content

Instantly share code, notes, and snippets.

@bramus
Created November 22, 2018 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bramus/ff428c5e7a7862cc0ecfe6f7b11ea9bb to your computer and use it in GitHub Desktop.
Save bramus/ff428c5e7a7862cc0ecfe6f7b11ea9bb to your computer and use it in GitHub Desktop.
<?php
// @ref https://twitter.com/brendt_gd/status/1065534180266782721
$a = range(5, 8);
$b = range(13,16);
$c = range(1,3);
$current = range(1,16);
$a = array_combine($a, array_fill(0, sizeof($a), 1)) + array_combine($current, array_fill(0, sizeof($current), 0));
$b = array_combine($b, array_fill(0, sizeof($b), 1)) + array_combine($current, array_fill(0, sizeof($current), 0));
$c = array_combine($c, array_fill(0, sizeof($c), 1)) + array_combine($current, array_fill(0, sizeof($current), 0));
$diff = [];
foreach ($current as $index) {
if ($a[$index] xor $b[$index] xor $c[$index] xor 1) {
$diff[] = $index;
}
}
var_dump(implode(',', $diff)); // 4,9,10,11,12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment