Skip to content

Instantly share code, notes, and snippets.

@magmastonealex
Last active December 24, 2015 14:59
Show Gist options
  • Save magmastonealex/6816828 to your computer and use it in GitHub Desktop.
Save magmastonealex/6816828 to your computer and use it in GitHub Desktop.
<?php
$troutcost = 1;
$pikecost = 2;
$piccost = 3;
$total = 2;
$totalposs = 0;
for($numt=0; $numt <= floor($total/$troutcost); $numt++){
for($numpi=0; $numpi <= floor($total/$pikecost); $numpi++){
for($numpic=0; $numpic <= floor($total/$piccost); $numpic++){
$t = (($numt*$troutcost)+($numpi*$pikecost)+($numpic*$piccost));
if((($numt*$troutcost)+($numpi*$pikecost)+($numpic*$piccost)) != $total){
if(!($numt == 0 && $numpic == 0 && $numpi == 0)){
echo "$numt Brown Trout, $numpi Northern Pike, $numpic Yellow Pickerel<br>";
$totalposs++;
}
}
}
}
}
echo "Total Ways to Catch Fish: $totalposs"
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment