SHARE
TWEET

Untitled

a guest Sep 17th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. public function getClosestPerfectNumber($nbFighters){
  3.         $perfectNumbers = $this->perfectNumbers;
  4.         foreach ($perfectNumbers as $key => $perfectNumber) {
  5.             if($nbFighters < $perfectNumber){
  6.                 return array(
  7.                     'roundNumber' => $key - 1 ,
  8.                     'roundName' => isset($perfectNumbers[$key - 2]) ? $this->getRoundName($perfectNumbers[$key - 2]) : 'Final 1-2',
  9.                     'value' => isset($perfectNumbers[$key - 1]) ? $perfectNumbers[$key - 1] : 0,
  10.                 );
  11.             }elseif($nbFighters === $perfectNumber){
  12.                 return array(
  13.                     'roundNumber' => $key,
  14.                     'roundName' => isset($perfectNumbers[$key - 2]) ? $this->getRoundName($perfectNumbers[$key - 1]) : 'Final 1-2',
  15.                     'value' => $perfectNumbers[$key],
  16.                 );
  17.             }
  18.         }
  19.         return false;
  20.     }
  21.  
  22.     private function getPerfectNumbers(){
  23.         $numbers[] = 1;
  24.         for($i = 1; $i < 20; $i++){
  25.             $numbers[] = $numbers[count($numbers) - 1] * 2;
  26.         }
  27.  
  28.         return $numbers;
  29.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top