function recursewalk(&$TREE, $i)
{
    $TREE[$i]['flag'] = 1;
    foreach ($TREE[$i]['nodes'] as $k => $r) {
        $TREE[$r]['total'] = calcCost($TREE, $i, $k);
        recursewalk($TREE, $r);
    }
}
function gextri($ROOMS)
{
    $timestart = microtime(1);
    $cnt = count($ROOMS) - 1;
    for ($i = 0; $i < $cnt; $i++) {
        $r = $ROOMS[$i][0];
        $ROOMS[$r]['total'] = calcCost($ROOMS, $i, 0);
        $r = $ROOMS[$i][1];
        $ROOMS[$r]['total'] = calcCost($ROOMS, $i, 1);
    }
    error_log(var_export('calculate cost - ' . (microtime(1) - $timestart), true));
    return searchMax($ROOMS);
}
Example #3
0
  <?php 
echo getFullName();
?>
 <br /> <br />
				
				Thank you for joining us this weekend! We look forward to seeing you at this years
				hackathon and wish you and your team great success.
				<br /><br />
				Swimmingly, <br /><br />
				  Joe Otter
				</p>
				
				<br />

				<span class="total"> Your total: <?php 
echo "\$" . calcCost();
?>
 </span>
			</div>

				<!-- Footer section -->
				<footer>
					<hr />
					<figure >
						<img class="footerLogoImage" src="./Media/Images/csumb-logo.png"
						alt="Image of Otter and first letters of the university, which are M & B" />
					</figure>
					This site is ONLY intended as an educational tool for building HTML pages. The site content
					is strictly sample text only. Richard Ciampa &copy; All Rights reserved
				</footer>
		</div>
    {
        $cost = weekstoDays($length);
        if ($location == "Online") {
            $cost = $cost / 2;
            return $cost;
        } else {
            return $cost;
        }
    }
    if ($errMsg != "") {
        echo "<h2>Please correct the following errors before submitting again:</h2>\n\t\t\t<p>{$errMsg}</p>";
    } else {
        $_SESSION["firstname"] = $firstname;
        $_SESSION["lastname"] = $lastname;
        $_SESSION["email"] = $email;
        $_SESSION["streetAddress"] = $streetaddress;
        $_SESSION["suburb"] = $suburb;
        $_SESSION["state"] = $state;
        $_SESSION["postcode"] = $postcode;
        $_SESSION["phone"] = $phone;
        $_SESSION["course"] = $course;
        $_SESSION["location"] = $location;
        $_SESSION["length"] = $length;
        $_SESSION["seats"] = $seats;
        $_SESSION["comments"] = $comments;
        $_SESSION["cost"] = calcCost($location, $length);
        header("location:payment.php");
    }
} else {
    header("location:enquire.php");
}
Example #5
0
    $d = 0;
    $a = 0;
    foreach ($inv as $item) {
        $d += $item->damage;
        $a += $item->armor;
    }
    return array('h' => 100, 'a' => $a, 'd' => $d);
}
function isWinner(array $player, array $boss)
{
    $playerDamage = max(array(1, $player['d'] - $boss['a']));
    $bossDamage = max(array(1, $boss['d'] - $player['a']));
    return ceil($player['h'] / $bossDamage) >= ceil($boss['h'] / $playerDamage);
}
$lowestCost = PHP_INT_MAX;
foreach ($items['w'] as $w) {
    foreach ($items['a'] as $a) {
        foreach ($items['r'] as $r1) {
            foreach ($items['r'] as $r2) {
                if ($r1 === $r2) {
                    continue;
                }
                $playerItems = array($w, $a, $r1, $r2);
                if (isWinner(calcStats($playerItems), $bossStats)) {
                    $lowestCost = min(array($lowestCost, calcCost($playerItems)));
                }
            }
        }
    }
}
echo 'Answer: ' . $lowestCost;
Example #6
0
    $d = 0;
    $a = 0;
    foreach ($inv as $item) {
        $d += $item->damage;
        $a += $item->armor;
    }
    return array('h' => 100, 'a' => $a, 'd' => $d);
}
function isWinner(array $player, array $boss)
{
    $playerDamage = max(array(1, $player['d'] - $boss['a']));
    $bossDamage = max(array(1, $boss['d'] - $player['a']));
    return ceil($player['h'] / $bossDamage) >= ceil($boss['h'] / $playerDamage);
}
$highestCost = 0;
foreach ($items['w'] as $w) {
    foreach ($items['a'] as $a) {
        foreach ($items['r'] as $r1) {
            foreach ($items['r'] as $r2) {
                if ($r1 === $r2) {
                    continue;
                }
                $playerItems = array($w, $a, $r1, $r2);
                if (!isWinner(calcStats($playerItems), $bossStats)) {
                    $highestCost = max(array($highestCost, calcCost($playerItems)));
                }
            }
        }
    }
}
echo 'Answer: ' . $highestCost;