Skip to content

Instantly share code, notes, and snippets.

@phptek
Created November 24, 2016 04:53
Show Gist options
  • Save phptek/1c502465c97b7ff18864b65bd2d52ff5 to your computer and use it in GitHub Desktop.
Save phptek/1c502465c97b7ff18864b65bd2d52ff5 to your computer and use it in GitHub Desktop.
stiff
<?php
$wanted = array(2, 4, 6);
$not_wanted = array(3, 5);
$candidates_w = $candiates_nw = [];
for ($i=0; $i < 100; $i++)
{
foreach ($wanted as $w_permid) {
if ($w_permid & $i) {
$candidates_w[$i][$w_permid][] = $i;
}
}
foreach ($not_wanted as $nw_permid) {
if (!($nw_permid & $i)) {
$candidates_nw[$i][$nw_permid][] = $i;
}
}
}
if ($argv[2] === 'w') {
var_dump($candidates_w);
}
if ($argv[2] === 'nw') {
var_dump($candidates_nw);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment