$Wrappers_On_Hand = $Wrappers_On_Hand % $M_Wrappers_Reqd; EchoBug("While: Remaining Wrappers_On_Hand", $Wrappers_On_Hand, 1); // Keep a running total of all Chockos Bought & Traded $Total_Chockos_On_Hand += $New_Chockos; EchoBug("While: Total_Chockos_On_Hand", $Total_Chockos_On_Hand, 0); } // End While // Write Final Answer $FinalAnswer = $Total_Chockos_On_Hand; if (ShowOutput == "YES") { echo "<strong><em>"; } if (ShowOutput == "YES") { echo $Set_While_Loop_Ran ? "While Loop Ran" . aNewLine : "While Loop SKIPPED" . aNewLine; } EchoAnswer("fwrite Total Chocolates", $FinalAnswer, 1); if (ShowOutput == "YES") { echo "</strong></em>"; } fwrite($OutPutFileHandle, $FinalAnswer); fwrite($OutPutFileHandle, "\n"); } // End For $NumRecordsToCheck // Close Files fclose($InPutFileHandle); fclose($OutPutFileHandle); // End Main ?> <h2>Done!</h2>
$d_DigitsArray = array_unique($d_DigitsArray); EchoBug("ARRAY d_DigitsArray", $d_DigitsArray, 1); // Do the Maths // For Each item in the array, check to see if it divides evenly (mod == 0) into the original number. $ArrayLength = sizeof($d_DigitsArray); foreach ($d_DigitsArray as $value) { if ($value != 0) { EchoBug("{$value}", $value, 1); if ($d_Digits % $value == 0) { $FinalAnswer += 1; } } } // end ForEach // Write answer for each line of input fwrite($OutPutFileHandle, $FinalAnswer); fwrite($OutPutFileHandle, "\n"); EchoAnswer("FinalAnswer", $FinalAnswer, 0); } // End For $TestCases // Close Files fclose($InPutFileHandle); fclose($OutPutFileHandle); // End Main ?> <h2>Done!</h2> </body> </html>
EchoBug("b_IndexEnd", $b_IndexEnd, 0); // intval the last array item to get rid of the trailing "\n" $k_Kandies = intval($InputArray[2]); // Wrappers needed to get another piece of chocolate EchoBug("k_Kandies", $k_Kandies, 0); // Do the Maths $JarsToFill = $b_IndexEnd - $a_IndexStart + 1; $KandiesTotal += $JarsToFill * $k_Kandies; } // End For $NumOperations // Write Final Answer $FinalAnswer = intval($KandiesTotal / $NumJars); if (ShowOutput == "YES") { echo "<strong><em>"; } EchoAnswer("fwrite Average Kandies", $FinalAnswer, 1); if (ShowOutput == "YES") { echo "</strong></em>"; } fwrite($OutPutFileHandle, $FinalAnswer); fwrite($OutPutFileHandle, "\n"); // Close Files fclose($InPutFileHandle); fclose($OutPutFileHandle); // End Main ?> <h2>Done!</h2> </body> </html>
// end for $jjj } // End For $TestCases // Write Final Answer // Dummy data for testing sort and unique // $StonesArray = $FinalAnswer; EchoBug("Stones Array", $StonesArray, 1); $StonesArray = array_unique($StonesArray); EchoBug("Final Answer", $StonesArray, 1); sort($StonesArray); EchoBug("Sorted Answer", $StonesArray, 1); $FinalAnswer = implode(" ", $StonesArray); if (ShowOutput == "YES") { echo "<strong><em>"; } EchoAnswer("fwrite ", $FinalAnswer, 1); if (ShowOutput == "YES") { echo "</strong></em>"; } fwrite($OutPutFileHandle, $FinalAnswer); fwrite($OutPutFileHandle, "\n"); // Close Files fclose($InPutFileHandle); fclose($OutPutFileHandle); // End Main ?> <h2>Done!</h2> </body> </html>
EchoBug("a_Low", $a_Low, 0); $b_High = intval($InputLineArray[1]); EchoBug("b_High", $b_High, 1); // Do the Maths $LowInt = ceil(sqrt($a_Low)); EchoBug("LowInt", $LowInt, 0); $HighInt = floor(sqrt($b_High)); EchoBug("HighInt", $HighInt, 0); $DeAnswer = $HighInt - $LowInt + 1; EchoBug("DeAnswer", $DeAnswer, 1); // Write answer line by line $LineAnswer = $DeAnswer; if (ShowOutput == "YES") { echo "<strong><em>"; } EchoAnswer("fwrite ", $LineAnswer, 1); if (ShowOutput == "YES") { echo "</strong></em>"; } fwrite($OutPutFileHandle, $LineAnswer); fwrite($OutPutFileHandle, "\n"); } // End For $TestCases // Write Final Answer // $FinalAnswer = $DeAnswer; // if (ShowOutput == "YES") echo "<strong><em>"; // EchoAnswer("fwrite ", $FinalAnswer, 1); // if (ShowOutput == "YES") echo "</strong></em>"; // fwrite($OutPutFileHandle, $FinalAnswer); // fwrite($OutPutFileHandle, "\n"); // Close Files