Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $batches = intval(readline());
- $hasFlour = false;
- $hasEggs = false;
- $hasSugar = false;
- for ($i = 1; $i <= $batches; $i++) {
- while ($i<=$batches) {
- $ingredient = readline();
- if ($ingredient === "Bake!") {
- if ($hasFlour && $hasEggs && $hasSugar) {
- $hasEggs = false;
- $hasFlour = false;
- $hasSugar = false;
- echo "Baking batch number $i..." . PHP_EOL;
- break;
- }else {
- echo "The batter should contain flour, eggs and sugar!".PHP_EOL;
- }
- } else {
- if ($ingredient === "flour") {
- $hasFlour = true;
- } else if ($ingredient === "eggs") {
- $hasEggs = true;
- } else if ($ingredient === "sugar") {
- $hasSugar = true;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement