Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $tasks = array_map("intval", explode(" ", readline()));
- $input = readline();
- while ($input !== "End") {
- $args = explode(" ", $input);
- $command = $args[0];
- $index = $args[1];
- switch ($command) {
- case "Complete":
- if ($index >= 0 && $index < count($tasks)) {
- $tasks[$index] = 0;
- }
- break;
- case "Drop":
- if ($index >= 0 && $index < count($tasks)) {
- $tasks[$index] = -1;
- }
- break;
- case "Change":
- $time = intval($args[2]);
- if ($index >= 0 && $index < count($tasks)) {
- $tasks[$index] = $time;
- }
- break;
- case "Count":
- $type = $args[1];
- $droppedCount = 0;
- $completeCount = 0;
- $incompleteCount = 0;
- for ($i = 0; $i < count($tasks); $i++) {
- $current = intval($tasks[$i]);
- if ($current < 0) {
- $droppedCount++;
- } else if ($current === 0) {
- $completeCount++;
- } else {
- $incompleteCount++;
- }
- }
- if ($type === "Dropped") {
- echo $droppedCount . PHP_EOL;
- } else if ($type === "Completed") {
- echo $completeCount . PHP_EOL;
- } else {
- echo $incompleteCount . PHP_EOL;
- }
- break;
- }
- $input = readline();
- }
- for ($i = 0; $i < count($tasks); $i++) {
- if ($tasks[$i] > 0) {
- echo "$tasks[$i] ";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement