{"id":804,"date":"2026-03-19T21:19:24","date_gmt":"2026-03-19T17:19:24","guid":{"rendered":"https:\/\/avdeevk.ru\/?p=804"},"modified":"2026-03-19T21:19:26","modified_gmt":"2026-03-19T17:19:26","slug":"python-middle-game-goblin","status":"publish","type":"post","link":"https:\/\/avdeevk.ru\/index.php\/2026\/03\/19\/python-middle-game-goblin\/","title":{"rendered":"Python.Middle: \u041a\u043e\u0434 \u0438\u0433\u0440\u044b \u00ab\u0414\u043e\u043c\u043e\u0432\u043e\u0439\u00bb"},"content":{"rendered":"\n<p>\u0422\u0443\u0442 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430\u0448\u0435\u0439 \u0438\u0433\u0440\u044b \u00ab\u0414\u043e\u043c\u043e\u0432\u043e\u0439\u00bb.<\/p>\n\n\n\n<p>\u042f \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u043e\u0447\u0438\u0441\u0442\u043a\u0443 \u044d\u043a\u0440\u0430\u043d\u0430 \u0438 \u0446\u0432\u0435\u0442\u043d\u043e\u0439 \u0432\u044b\u0432\u043e\u0434 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import random\nimport time\nimport subprocess\nimport platform\n\n# \u0420\u0435\u0431\u044f\u0442\u0430, \u0442\u0443\u0442 \u044f \u043d\u0430\u0437\u043d\u0430\u0447\u0430\u044e \u0446\u0432\u0435\u0442\u0430 \u0434\u043b\u044f \u043d\u0430\u0434\u043f\u0438\u0441\u0435\u0439, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u043b \u0446\u0432\u0435\u0442\u043d\u043e\u0439 \u0432\u044b\u0432\u043e\u0434!\nRESET = \"\\033&#91;0m\"      # \u0421\u0431\u0440\u043e\u0441 \u0446\u0432\u0435\u0442\u0430\nRED = \"\\033&#91;91m\"       # \u041a\u0440\u0430\u0441\u043d\u044b\u0439\nGREEN = \"\\033&#91;92m\"     # \u0417\u0435\u043b\u0435\u043d\u044b\u0439\nYELLOW = \"\\033&#91;93m\"    # \u0416\u0435\u043b\u0442\u044b\u0439\n\n# \u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u0447\u0438\u0449\u0430\u0435\u0442 \u044d\u043a\u0440\u0430\u043d \u043a\u043e\u043d\u0441\u043e\u043b\u0438! \u0414\u043b\u044f \u043a\u0440\u0430\u0441\u043e\u0442\u044b =)\ndef ClearScreen():\n    command = 'cls' if platform.system() == 'Windows' else 'clear'\n    subprocess.run(command, shell=True)\n\nTASK_POOL = &#91;\n    \"\u0423\u0431\u0440\u0430\u0442\u044c \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u0443\",\n    \"\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0442\u0440\u0443\u0431\u044b\",\n    \"\u041d\u0430\u043f\u0443\u0433\u0430\u0442\u044c \u0436\u0438\u043b\u044c\u0446\u043e\u0432\",\n    \"\u041f\u043e\u043a\u043e\u0440\u043c\u0438\u0442\u044c \u0441\u043e\u0431\u0430\u043a\u0443\"\n]\n\nPLACES_POOL = &#91;100,101,102,103,104,105]\nday = &#91;]\n\ndef GenerateDay():\n    day = &#91;]\n    placePool = &#91; PLACES_POOL&#91;random.randint(0,len(PLACES_POOL)-1)] for i in range(random.randint(3,7)) ]\n    for place in placePool:\n        day.append( { place: TASK_POOL&#91; random.randint(0, len(TASK_POOL) - 1)] })\n    return day\n\ndef Timer(func):\n    def wrapper(*args, **kwargs):\n        startTime = time.time()\n        result = func(*args, **kwargs)\n        endTime = time.time()\n        if(endTime - startTime > 10):\n            print(f\"{GREEN}\u0412\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f: {endTime - startTime} \u0441\u0435\u043a\u0443\u043d\u0434{RESET}\")\n        return result\n    return wrapper\n\ndef PrintDay(day):\n    for tasknplace in day:\n        for place, task in tasknplace.items():\n            print(f\"\u0417\u0430\u0434\u0430\u0447\u0430: {task}, \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u0430 {place}\")\n\ndef startDay():\n    global day\n    if len(day)  != 0:\n        print(f\"{RED}\u0422\u0430\u043a-\u0442\u043e \u0434\u0435\u043d\u044c \u0443\u0436\u0435 \u043d\u0430\u0447\u0430\u043b\u0441\u044f!{RESET}\")\n        return\n    day = GenerateDay()\n    ClearScreen()\n    print(f\"{YELLOW}\u0417\u0430\u0434\u0430\u0447\u0438 \u0431\u044b\u043b\u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b! \u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0439\u0442\u0435 \u043a \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e!{RESET}\")\n\ndef CompleteTask(place, task):\n    global day\n    if {place:task} in day:\n        day.remove({place:task})\n        ClearScreen()\n        print(f\"{GREEN}\u0417\u0430\u0434\u0430\u043d\u0438\u0435 \\\"{task}\\\" \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043e!{RESET}\")\n    else:\n        print(f\"{RED}\u041e\u0448\u0438\u0431\u043a\u0430! \u041d\u0435\u0442 \u0442\u0430\u043a\u043e\u0433\u043e \u0437\u0430\u0434\u0430\u043d\u0438\u044f!{RESET} \")\n        print(f\"{YELLOW}\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0437\u0430\u0434\u0430\u043d\u0438\u0439: {len(day)}{RESET}\")\n\n@Timer\ndef CompleteDay():\n    global day\n    if len(day) == 0:\n        ClearScreen()\n        print(f\"{RED}\u0414\u0435\u043d\u044c \u0435\u0449\u0451 \u043d\u0435 \u043d\u0430\u0447\u0430\u043b\u0441\u044f!{RESET}\")\n        \n        return\n    \n    while len(day) != 0:\n        PrintDay(day)\n        try:\n            place,task = input(\"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0447\u0435\u0440\u0435\u0437 \u0437\u0430\u043f\u044f\u0442\u0443\u044e \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u0443 \u0438 \u0437\u0430\u0434\u0430\u0447\u0443: \").split(\",\")\n            place = int(place.strip())\n        except Exception as e:\n            print(f\"{RED}\u041d\u0435\u0432\u0435\u0440\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435: {e}{RESET}\")\n            continue\n        CompleteTask(place, task.strip())\n    ClearScreen()\n    print(f\"{GREEN}\u0414\u0435\u043d\u044c \u0437\u0430\u0432\u0435\u0440\u0448\u0451\u043d...{RESET}\")\n\nmethods = {\n    1 : &#91;\"\u041d\u0430\u0447\u0430\u0442\u044c \u0434\u0435\u043d\u044c\", startDay],\n    2 : &#91;\"\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0438\", CompleteDay],\n    3 : &#91;\"\u0412\u044b\u0439\u0442\u0438\", lambda:exit(0)]\n}\n\nwhile True:\n    for method in methods.keys():\n        print(f\"{method}. {methods&#91;method]&#91;0]}\")\n    try:\n        choice = int(input(\"\u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u043f\u0443\u043d\u043a\u0442 \u043c\u0435\u043d\u044e: \"))\n        if choice not in methods.keys():\n            continue\n        methods&#91;choice]&#91;1]()\n    except Exception as e:\n        print(f\"{RED}\u041d\u0435\u0432\u0435\u0440\u043d\u044b\u0439 \u0432\u0432\u043e\u0434! \u0411\u0443\u0434\u044c \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u0435\u0435! {e}{RESET}\")<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0422\u0443\u0442 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430\u0448\u0435\u0439 \u0438\u0433\u0440\u044b \u00ab\u0414\u043e\u043c\u043e\u0432\u043e\u0439\u00bb. \u042f \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u043e\u0447\u0438\u0441\u0442\u043a\u0443 \u044d\u043a\u0440\u0430\u043d\u0430 \u0438 \u0446\u0432\u0435\u0442\u043d\u043e\u0439 \u0432\u044b\u0432\u043e\u0434 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[30,31,12],"tags":[],"class_list":["post-804","post","type-post","status-publish","format-standard","hentry","category-topit","category-topit-tuts","category-tuts"],"_links":{"self":[{"href":"https:\/\/avdeevk.ru\/index.php\/wp-json\/wp\/v2\/posts\/804","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/avdeevk.ru\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/avdeevk.ru\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/avdeevk.ru\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/avdeevk.ru\/index.php\/wp-json\/wp\/v2\/comments?post=804"}],"version-history":[{"count":1,"href":"https:\/\/avdeevk.ru\/index.php\/wp-json\/wp\/v2\/posts\/804\/revisions"}],"predecessor-version":[{"id":805,"href":"https:\/\/avdeevk.ru\/index.php\/wp-json\/wp\/v2\/posts\/804\/revisions\/805"}],"wp:attachment":[{"href":"https:\/\/avdeevk.ru\/index.php\/wp-json\/wp\/v2\/media?parent=804"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/avdeevk.ru\/index.php\/wp-json\/wp\/v2\/categories?post=804"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/avdeevk.ru\/index.php\/wp-json\/wp\/v2\/tags?post=804"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}