|
46 | 46 | "string = input()\n",
|
47 | 47 | "string_list = string.split()\n",
|
48 | 48 | "string_list_print = []\n",
|
| 49 | + "\n", |
49 | 50 | "for index in range(len(string_list)):\n",
|
50 | 51 | " number = int(string_list[index]) * -1\n",
|
51 | 52 | " string_list_print.append(number)\n",
|
| 53 | + " \n", |
52 | 54 | "print(string_list_print)"
|
53 | 55 | ]
|
54 | 56 | },
|
|
84 | 86 | "source": [
|
85 | 87 | "first_number = int(input())\n",
|
86 | 88 | "second_number = int(input())\n",
|
| 89 | + "\n", |
87 | 90 | "numbers_list = []\n",
|
| 91 | + "\n", |
88 | 92 | "for num in range(1, (first_number * second_number) + 1):\n",
|
89 | 93 | " if num % first_number == 0:\n",
|
90 | 94 | " numbers_list.append(num)\n",
|
| 95 | + " \n", |
91 | 96 | "print(numbers_list)"
|
92 | 97 | ]
|
93 | 98 | },
|
|
153 | 158 | }
|
154 | 159 | ],
|
155 | 160 | "source": [
|
156 |
| - "cards_input = input()\n", |
157 |
| - "cards_input_list = set(cards_input.split())\n", |
| 161 | + "cards_input = set(input().split())\n", |
| 162 | + "\n", |
158 | 163 | "players_A_team = 11\n",
|
159 | 164 | "players_B_team = 11\n",
|
160 | 165 | "terminated = False\n",
|
161 |
| - "for card in cards_input_list:\n", |
| 166 | + "\n", |
| 167 | + "for card in cards_input:\n", |
| 168 | + " \n", |
162 | 169 | " if card[0] == \"A\":\n",
|
163 | 170 | " players_A_team -= 1\n",
|
164 | 171 | " else:\n",
|
165 | 172 | " players_B_team -= 1\n",
|
| 173 | + " \n", |
166 | 174 | " if players_B_team < 7 or players_A_team < 7:\n",
|
167 | 175 | " terminated = True\n",
|
168 | 176 | " break\n",
|
| 177 | + " \n", |
169 | 178 | "print(f\"Team A - {players_A_team}; Team B - {players_B_team}\")\n",
|
| 179 | + "\n", |
170 | 180 | "if terminated:\n",
|
171 | 181 | " print(\"Game was terminated\")"
|
172 | 182 | ]
|
|
232 | 242 | }
|
233 | 243 | ],
|
234 | 244 | "source": [
|
235 |
| - "numbers = input()\n", |
| 245 | + "numbers_list = input().split(\", \")\n", |
236 | 246 | "beggars = int(input())\n",
|
237 |
| - "numbers_list = numbers.split(\", \")\n", |
| 247 | + "\n", |
238 | 248 | "numbers_list_print = []\n",
|
239 | 249 | "begin_from = 0\n",
|
240 | 250 | "sum_numbers = 0\n",
|
| 251 | + "\n", |
241 | 252 | "for beggar in range(beggars):\n",
|
| 253 | + " \n", |
242 | 254 | " for i in range(begin_from, len(numbers_list), beggars):\n",
|
243 | 255 | " sum_numbers += int(numbers_list[i])\n",
|
| 256 | + " \n", |
244 | 257 | " numbers_list_print.append(sum_numbers)\n",
|
245 | 258 | " sum_numbers = 0\n",
|
246 | 259 | " begin_from += 1\n",
|
| 260 | + " \n", |
247 | 261 | "print(numbers_list_print)"
|
248 | 262 | ]
|
249 | 263 | },
|
|
281 | 295 | }
|
282 | 296 | ],
|
283 | 297 | "source": [
|
284 |
| - "cards = input()\n", |
| 298 | + "cards = input().split(\" \")\n", |
285 | 299 | "shuffles = int(input())\n",
|
286 |
| - "cards_list = cards.split(\" \")\n", |
| 300 | + "\n", |
287 | 301 | "new_card_list_print = []\n",
|
288 | 302 | "new_card_list = []\n",
|
289 |
| - "slice_place = int(len(cards_list) / 2)\n", |
290 |
| - "first_half_cards_list = cards_list[:slice_place]\n", |
291 |
| - "second_half_cards_list = cards_list[slice_place:]\n", |
| 303 | + "slice_place = int(len(cards) / 2)\n", |
| 304 | + "first_half_cards_list = cards[:slice_place]\n", |
| 305 | + "second_half_cards_list = cards[slice_place:]\n", |
| 306 | + "\n", |
292 | 307 | "for shuffle in range(shuffles):\n",
|
| 308 | + "\n", |
293 | 309 | " for card in range(slice_place):\n",
|
294 | 310 | " new_card_list.append(first_half_cards_list[card])\n",
|
295 | 311 | " new_card_list.append(second_half_cards_list[card])\n",
|
| 312 | + "\n", |
296 | 313 | " first_half_cards_list = new_card_list[:slice_place]\n",
|
297 | 314 | " second_half_cards_list = new_card_list[slice_place:]\n",
|
298 | 315 | " new_card_list_print = new_card_list\n",
|
299 | 316 | " new_card_list = []\n",
|
| 317 | + "\n", |
300 | 318 | "print(new_card_list_print)"
|
301 | 319 | ]
|
302 | 320 | },
|
|
360 | 378 | "source": [
|
361 | 379 | "string_of_numbers = input()\n",
|
362 | 380 | "number = int(input())\n",
|
| 381 | + "\n", |
363 | 382 | "list_of_numbers = string_of_numbers.split(\" \")\n",
|
| 383 | + "\n", |
364 | 384 | "for i in range(len(list_of_numbers)):\n",
|
365 | 385 | " list_of_numbers[i] = int(list_of_numbers[i])\n",
|
| 386 | + " \n", |
366 | 387 | "for n in range(number):\n",
|
367 | 388 | " min_number = min(list_of_numbers)\n",
|
368 | 389 | " list_of_numbers.remove(min_number)\n",
|
| 390 | + " \n", |
369 | 391 | "print(list_of_numbers)"
|
370 | 392 | ]
|
371 | 393 | },
|
|
443 | 465 | }
|
444 | 466 | ],
|
445 | 467 | "source": [
|
446 |
| - "gifts_names = input()\n", |
| 468 | + "gifts_names = input().split(\" \")\n", |
447 | 469 | "command = input()\n",
|
448 |
| - "gifts_names_list = gifts_names.split(\" \")\n", |
| 470 | + "\n", |
449 | 471 | "while command != \"No Money\":\n",
|
450 | 472 | " command_list = command.split(\" \")\n",
|
| 473 | + "\n", |
451 | 474 | " if command_list[0] == \"OutOfStock\":\n",
|
452 |
| - " if command_list[1] in gifts_names_list:\n", |
453 |
| - " for i in range(len(gifts_names_list)):\n", |
454 |
| - " if gifts_names_list[i] == command_list[1]:\n", |
455 |
| - " gifts_names_list[i] = \"None\"\n", |
| 475 | + " if command_list[1] in gifts_names:\n", |
| 476 | + " for i in range(len(gifts_names)):\n", |
| 477 | + " if gifts_names[i] == command_list[1]:\n", |
| 478 | + " gifts_names[i] = \"None\"\n", |
| 479 | + "\n", |
456 | 480 | " elif command_list[0] == \"Required\" and int(command_list[2]) > 0 and int(command_list[2]) <= int(\n",
|
457 |
| - " len(gifts_names_list)) - 1:\n", |
458 |
| - " gifts_names_list[int(command_list[2])] = command_list[1]\n", |
| 481 | + " len(gifts_names)) - 1:\n", |
| 482 | + " gifts_names[int(command_list[2])] = command_list[1]\n", |
| 483 | + "\n", |
459 | 484 | " elif command_list[0] == \"JustInCase\":\n",
|
460 |
| - " gifts_names_list[int(len(gifts_names_list)) - 1] = command_list[1]\n", |
| 485 | + " gifts_names[int(len(gifts_names)) - 1] = command_list[1]\n", |
461 | 486 | " command = input()\n",
|
462 |
| - "for n in range(len(gifts_names_list)):\n", |
463 |
| - " if \"None\" in gifts_names_list:\n", |
464 |
| - " gifts_names_list.remove(\"None\")\n", |
465 |
| - "gifts_names_print = \" \".join(gifts_names_list)\n", |
| 487 | + "\n", |
| 488 | + "for n in range(len(gifts_names)):\n", |
| 489 | + " if \"None\" in gifts_names:\n", |
| 490 | + " gifts_names.remove(\"None\")\n", |
| 491 | + "\n", |
| 492 | + "gifts_names_print = \" \".join(gifts_names)\n", |
| 493 | + "\n", |
466 | 494 | "print(gifts_names_print)"
|
467 | 495 | ]
|
468 | 496 | },
|
|
566 | 594 | }
|
567 | 595 | ],
|
568 | 596 | "source": [
|
569 |
| - "fire = input()\n", |
| 597 | + "fire_list = input().split(\"#\")\n", |
570 | 598 | "water = int(input())\n",
|
571 |
| - "fire_list = fire.split(\"#\")\n", |
572 |
| - "new_fire_List = []\n", |
| 599 | + "\n", |
| 600 | + "RANGE_HIGH = range(81, 126)\n", |
| 601 | + "RANGE_MED = range(51, 81)\n", |
| 602 | + "RANGE_LOW = range(1, 51)\n", |
| 603 | + "\n", |
573 | 604 | "effort = 0\n",
|
574 |
| - "for i in fire_list:\n", |
575 |
| - " new_fire_List.append(i.split(' = '))\n", |
| 605 | + "fire_level_print = []\n", |
| 606 | + "\n", |
| 607 | + "for fire in fire_list:\n", |
| 608 | + " type_of_fire, fire_level = fire.split(\" = \")\n", |
| 609 | + " fire_level = int(fire_level)\n", |
| 610 | + "\n", |
| 611 | + " is_valid = (type_of_fire == type_of_fire == \"High\" and fire_level in RANGE_HIGH) or (\n", |
| 612 | + " type_of_fire == \"Medium\" and fire_level in RANGE_MED) or (type_of_fire == \"Low\" and fire_level in RANGE_LOW)\n", |
| 613 | + "\n", |
| 614 | + " if is_valid and water >= fire_level:\n", |
| 615 | + " water -= fire_level\n", |
| 616 | + " fire_level_print.append(fire_level)\n", |
| 617 | + " effort += fire_level\n", |
| 618 | + "\n", |
576 | 619 | "print(\"Cells:\")\n",
|
577 |
| - "for i in range(len(new_fire_List)):\n", |
578 |
| - " fire_type = new_fire_List[i][0]\n", |
579 |
| - " fire_level = int(new_fire_List[i][1])\n", |
580 |
| - " if fire_type == \"High\":\n", |
581 |
| - " if 81 <= int(new_fire_List[i][1]) <= 125:\n", |
582 |
| - " if water >= fire_level:\n", |
583 |
| - " water -= fire_level\n", |
584 |
| - " print(f\" - {fire_level}\")\n", |
585 |
| - " effort += fire_level\n", |
586 |
| - " if fire_type == \"Medium\":\n", |
587 |
| - " if 51 <= fire_level <= 80:\n", |
588 |
| - " if water >= fire_level:\n", |
589 |
| - " water -= fire_level\n", |
590 |
| - " print(f\" - {fire_level}\")\n", |
591 |
| - " effort += fire_level\n", |
592 |
| - " if fire_type == \"Low\":\n", |
593 |
| - " if 1 <= fire_level <= 50:\n", |
594 |
| - " if water >= fire_level:\n", |
595 |
| - " water -= fire_level\n", |
596 |
| - " print(f\" - {fire_level}\")\n", |
597 |
| - " effort += fire_level\n", |
| 620 | + "\n", |
| 621 | + "for fire_level in fire_level_print:\n", |
| 622 | + " print(f\" - {fire_level}\")\n", |
| 623 | + " \n", |
598 | 624 | "print(f\"Effort: {(effort * 0.25):.2f}\")\n",
|
599 | 625 | "print(f\"Total Fire: {effort}\")"
|
600 | 626 | ]
|
|
686 | 712 | }
|
687 | 713 | ],
|
688 | 714 | "source": [
|
689 |
| - "items_and_prices = input()\n", |
| 715 | + "items_and_prices = input().split(\"|\")\n", |
690 | 716 | "budget = float(input())\n",
|
691 |
| - "items_and_prices_list = items_and_prices.split(\"|\")\n", |
| 717 | + "\n", |
692 | 718 | "new_items_and_prices_list = []\n",
|
693 | 719 | "increase_price = 0\n",
|
694 | 720 | "increase_price_list = []\n",
|
695 | 721 | "profit = 0\n",
|
696 | 722 | "sum_increase_price = 0\n",
|
697 |
| - "for i in items_and_prices_list:\n", |
698 |
| - " new_items_and_prices_list.append(i.split(\"->\"))\n", |
699 |
| - "for i in range(len(new_items_and_prices_list)):\n", |
700 |
| - " item_type = new_items_and_prices_list[i][0]\n", |
701 |
| - " price = float(new_items_and_prices_list[i][1])\n", |
702 |
| - " if item_type == \"Clothes\":\n", |
703 |
| - " if price <= 50:\n", |
704 |
| - " if budget >= price:\n", |
705 |
| - " budget -= price\n", |
706 |
| - " increase_price = price * 1.4\n", |
707 |
| - " sum_increase_price += increase_price\n", |
708 |
| - " increase_price_list.append(f\"{increase_price:.2f}\")\n", |
709 |
| - " profit += ((price * 1.4) - price)\n", |
710 |
| - " elif item_type == \"Shoes\":\n", |
711 |
| - " if price <= 35:\n", |
712 |
| - " if budget >= price:\n", |
713 |
| - " budget -= price\n", |
714 |
| - " increase_price = price * 1.4\n", |
715 |
| - " sum_increase_price += increase_price\n", |
716 |
| - " increase_price_list.append(f\"{increase_price:.2f}\")\n", |
717 |
| - " profit += ((price * 1.4) - price)\n", |
718 |
| - " elif item_type == \"Accessories\":\n", |
719 |
| - " if price <= 20.5:\n", |
720 |
| - " if budget >= price:\n", |
721 |
| - " budget -= price\n", |
722 |
| - " increase_price = price * 1.4\n", |
723 |
| - " sum_increase_price += increase_price\n", |
724 |
| - " increase_price_list.append(f\"{increase_price:.2f}\")\n", |
725 |
| - " profit += ((price * 1.4) - price)\n", |
| 723 | + "\n", |
| 724 | + "for i in items_and_prices:\n", |
| 725 | + " item_type, price = i.split(\"->\")\n", |
| 726 | + " price = float(price)\n", |
| 727 | + "\n", |
| 728 | + " is_valid = (item_type == \"Clothes\" and price <= 50) or (item_type == \"Shoes\" and price <= 35) or (\n", |
| 729 | + " item_type == \"Accessories\" and price <= 20.5)\n", |
| 730 | + "\n", |
| 731 | + " if is_valid and budget >= price:\n", |
| 732 | + " budget -= price\n", |
| 733 | + " increase_price = price * 1.4\n", |
| 734 | + " sum_increase_price += increase_price\n", |
| 735 | + " increase_price_list.append(f\"{increase_price:.2f}\")\n", |
| 736 | + " profit += ((price * 1.4) - price)\n", |
| 737 | + "\n", |
726 | 738 | "items_and_prices_print = \" \".join(increase_price_list)\n",
|
| 739 | + "\n", |
727 | 740 | "print(items_and_prices_print)\n",
|
728 | 741 | "print(f\"Profit: {profit:.2f}\")\n",
|
| 742 | + "\n", |
729 | 743 | "if (budget + sum_increase_price) >= 150:\n",
|
730 | 744 | " print(\"Hello, France!\")\n",
|
731 | 745 | "else:\n",
|
|
807 | 821 | }
|
808 | 822 | ],
|
809 | 823 | "source": [
|
810 |
| - "day_events = input()\n", |
811 |
| - "day_events_list = day_events.split(\"|\")\n", |
| 824 | + "day_events = input().split(\"|\")\n", |
| 825 | + "\n", |
812 | 826 | "new_day_events_list = []\n",
|
813 | 827 | "energy = 100\n",
|
814 | 828 | "coins = 100\n",
|
815 | 829 | "close = False\n",
|
816 |
| - "for i in day_events_list:\n", |
817 |
| - " new_day_events_list.append(i.split(\"-\"))\n", |
818 |
| - "for i in range(len(new_day_events_list)):\n", |
819 |
| - " event = new_day_events_list[i][0]\n", |
820 |
| - " number = int(new_day_events_list[i][1])\n", |
| 830 | + "\n", |
| 831 | + "for i in day_events:\n", |
| 832 | + " event, number = i.split(\"-\")\n", |
| 833 | + " number = int(number)\n", |
| 834 | + "\n", |
821 | 835 | " if event == \"rest\":\n",
|
822 | 836 | " if energy + number > 100:\n",
|
823 | 837 | " print(f\"You gained {100 - energy} energy.\")\n",
|
|
826 | 840 | " print(f\"You gained {number} energy.\")\n",
|
827 | 841 | " energy += number\n",
|
828 | 842 | " print(f\"Current energy: {energy}.\")\n",
|
| 843 | + "\n", |
829 | 844 | " elif event == \"order\":\n",
|
830 | 845 | " if energy >= 30:\n",
|
831 | 846 | " print(f\"You earned {number} coins.\")\n",
|
|
834 | 849 | " else:\n",
|
835 | 850 | " energy += 50\n",
|
836 | 851 | " print(\"You had to rest!\")\n",
|
| 852 | + "\n", |
837 | 853 | " elif event != \"order\" and event != \"rest\":\n",
|
838 | 854 | " if coins - number > 0:\n",
|
839 | 855 | " print(f\"You bought {event}.\")\n",
|
|
842 | 858 | " print(f\"Closed! Cannot afford {event}.\")\n",
|
843 | 859 | " close = True\n",
|
844 | 860 | " break\n",
|
| 861 | + "\n", |
845 | 862 | "if not close:\n",
|
846 | 863 | " print(f\"Day completed!\")\n",
|
847 | 864 | " print(f\"Coins: {coins}\")\n",
|
|
0 commit comments