Skip to content

Instantly share code, notes, and snippets.

@AkenRoberts
Created August 13, 2012 06:25
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 AkenRoberts/3337417 to your computer and use it in GitHub Desktop.
Save AkenRoberts/3337417 to your computer and use it in GitHub Desktop.
Loop Solution for Philbish
<?php
$a = array();
$max_odd = 93;
$max_even = 72;
$prefix = 'B-';
$o = -1;
$e = 0;
while ($o <= $max_odd OR $e <= $max_even)
{
for ($i = 0; $i < 2; $i++)
{
if (($e += 2) <= $max_even)
{
$a[] = $prefix.$e;
}
}
for ($i = 0; $i < 3; $i++)
{
if (($o += 2) <= $max_odd)
{
$a[] = $prefix.$o;
}
}
}
print_r($a);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment