Guest User

http://puzzling.stackexchange.com/questions/12138/how-to-max

a guest
Apr 15th, 2015
231
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $min_hour=100;
  3. $max_hour=192;
  4. $prob =0.01;
  5. while($prob <= 1){
  6.     for($i=$min_hour;$i<=$max_hour;$i++){
  7.         $hour_worked    =   $i;
  8.         $hour_reversed  =   (substr($i,-1).substr($i,-2,1) > 92)?$i:substr($i,-3,1).substr($i,-1).substr($i,-2,1);
  9.         $average    =   (((1-$prob)*$hour_worked ) + (($prob)*$hour_reversed ) )/2;
  10.         $array[$hour_worked][]=$average;
  11.     }
  12.     $prob=$prob + 0.01;
  13. }
  14. foreach($array as $key=>$val){
  15.     $average_of_foo = array_sum($val) / count($val);
  16.     echo $key." - ".$average_of_foo;
  17.     echo "<br>";
  18. }
  19. ?>
RAW Paste Data