Created
August 13, 2012 06:25
-
-
Save AkenRoberts/3337417 to your computer and use it in GitHub Desktop.
Loop Solution for Philbish
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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