{"id":33910,"date":"2024-11-01T09:21:53","date_gmt":"2024-11-01T09:21:53","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=33910"},"modified":"2024-11-01T10:55:05","modified_gmt":"2024-11-01T10:55:05","slug":"c-coding-test-course-jumongs-command","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/33910\/","title":{"rendered":"C# Coding Test Course, Jumong&#8217;s Command"},"content":{"rendered":"<p><body><\/p>\n<p>Hello! In this post, we will solve a coding test problem using the C# language. The topic is &#8216;Jumong&#8217;s Command&#8217;. This problem simulates the situation where Jumong issues commands and implements an algorithm to handle them efficiently. I will explain in detail how to solve the problem and implement the code.<\/p>\n<h2>Problem Description<\/h2>\n<p>Jumong gives commands to warriors before each battle. Each warrior performs their duties according to the commands they receive. The warriors interpret Jumong&#8217;s commands as follows:<\/p>\n<ul>\n<li>Warrior&#8217;s unique number (a positive integer starting from 1)<\/li>\n<li>Content of the command (indicates what action needs to be performed)<\/li>\n<\/ul>\n<p>Jumong has N warriors and M commands. The commands are given in the following format:<\/p>\n<pre>\n    1. ATTACK A B  \/\/ Warrior A attacks warrior B\n    2. DEFENSE A   \/\/ Warrior A assumes a defensive posture\n    3. RETREAT A    \/\/ Warrior A retreats\n    <\/pre>\n<p>If a warrior successfully performs their duty, the result should output &#8216;SUCCESS&#8217;, and if they fail, it should output &#8216;FAIL&#8217;. Warriors do not perform commands if they lose interest before executing the command. Interest decreases over time. If a warrior is in a situation where they cannot perform the command, &#8216;FAIL&#8217; should be printed.<\/p>\n<h2>Input Format<\/h2>\n<p>The input is given in the following format:<\/p>\n<pre>\n    N (number of warriors)\n    M (number of commands)\n    Interest decay rate (0 ~ 1)\n    Commands (M commands)\n    <\/pre>\n<h2>Output Format<\/h2>\n<p>The results are printed for each command. The results are listed in the same order as the commands.<\/p>\n<h2>Approach to the Problem<\/h2>\n<p>This problem requires an algorithm to process the given commands and determine whether each warrior can perform the commands. To solve the problem, I will consider the following steps:<\/p>\n<ol>\n<li>Create a data structure to store the warriors and command lists.<\/li>\n<li>Assume that each warrior initially has 100% interest.<\/li>\n<li>Decrease the warrior&#8217;s interest according to the given interest decay rate, and process each command while updating their status.<\/li>\n<li>Record success or failure based on the results of the commands.<\/li>\n<\/ol>\n<h2>Implementation<\/h2>\n<h3>Code Example<\/h3>\n<p>The following is a C# implementation based on the above approach:<\/p>\n<pre><code>\nusing System;\nusing System.Collections.Generic;\n\nnamespace JumongCommand\n{\n    class Warrior\n    {\n        public int Id { get; set; }\n        public double Interest { get; set; }\n\n        public Warrior(int id)\n        {\n            Id = id;\n            Interest = 1.0; \/\/ 100% interest\n        }\n    }\n\n    class Program\n    {\n        static void Main(string[] args)\n        {\n            int N = int.Parse(Console.ReadLine());\n            int M = int.Parse(Console.ReadLine());\n            double interestDecayRate = double.Parse(Console.ReadLine());\n\n            List<warrior> warriors = new List<warrior>();\n            for (int i = 1; i &lt;= N; i++)\n            {\n                warriors.Add(new Warrior(i));\n            }\n\n            List<string> results = new List<string>();\n            for (int i = 0; i &lt; M; i++)\n            {\n                string command = Console.ReadLine();\n                string[] parts = command.Split(' ');\n\n                if (parts[0] == \"ATTACK\")\n                {\n                    int attackerId = int.Parse(parts[1]);\n                    int targetId = int.Parse(parts[2]);\n                    ProcessAttack(warriors, results, attackerId, targetId);\n                }\n                else if (parts[0] == \"DEFENSE\")\n                {\n                    int defenderId = int.Parse(parts[1]);\n                    ProcessDefense(warriors, results, defenderId);\n                }\n                else if (parts[0] == \"RETREAT\")\n                {\n                    int retreatId = int.Parse(parts[1]);\n                    ProcessRetreat(warriors, results, retreatId);\n                }\n\n                \/\/ Apply interest decay\n                foreach (var warrior in warriors)\n                {\n                    warrior.Interest -= interestDecayRate;\n                    if (warrior.Interest &lt; 0)\n                        warrior.Interest = 0;\n                }\n            }\n\n            foreach (var result in results)\n            {\n                Console.WriteLine(result);\n            }\n        }\n\n        static void ProcessAttack(List<warrior> warriors, List<string> results, int attackerId, int targetId)\n        {\n            var attacker = warriors[attackerId - 1];\n            var target = warriors[targetId - 1];\n\n            if (attacker.Interest &gt; 0)\n            {\n                results.Add(\"SUCCESS\");\n            }\n            else\n            {\n                results.Add(\"FAIL\");\n            }\n        }\n\n        static void ProcessDefense(List<warrior> warriors, List<string> results, int defenderId)\n        {\n            var defender = warriors[defenderId - 1];\n\n            if (defender.Interest &gt; 0)\n            {\n                results.Add(\"SUCCESS\");\n            }\n            else\n            {\n                results.Add(\"FAIL\");\n            }\n        }\n\n        static void ProcessRetreat(List<warrior> warriors, List<string> results, int retreatId)\n        {\n            var retreatingWarrior = warriors[retreatId - 1];\n\n            if (retreatingWarrior.Interest &gt; 0)\n            {\n                results.Add(\"SUCCESS\");\n            }\n            else\n            {\n                results.Add(\"FAIL\");\n            }\n        }\n    }\n}\n<\/code><\/pre>\n<h2>Code Explanation<\/h2>\n<p>The code defines a &#8216;Warrior&#8217; class to manage the state of each warrior. Each warrior has a unique ID and a current interest as properties. The main program reads the warrior list and command list in order and calls separate methods to process each command, updating the results.<\/p>\n<h3>Verification of Results<\/h3>\n<p>After the commands are completed, the result list is printed to confirm the final success or failure results. This is a simple implementation of how warriors execute commands and manage resources.<\/p>\n<h2>Test Cases<\/h2>\n<p>We can create several test cases to check if it works properly.<\/p>\n<h3>Example Input<\/h3>\n<pre>\n5\n3\n0.1\nATTACK 1 2\nDEFENSE 3\nRETREAT 4\n<\/pre>\n<h3>Expected Results<\/h3>\n<pre>\nSUCCESS\nSUCCESS\nSUCCESS\n<\/pre>\n<p>By testing various inputs in this manner, we can check if the algorithm correctly responds to all situations.<\/p>\n<h2>Conclusion<\/h2>\n<p>In this post, we explored the process of solving the &#8216;Jumong&#8217;s Command&#8217; problem. Understanding the structure and implementation of the algorithm, as well as building the logic for processing various commands, was important. I hope you continue to improve your skills through more algorithm problems. Thank you!<\/p>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello! In this post, we will solve a coding test problem using the C# language. The topic is &#8216;Jumong&#8217;s Command&#8217;. This problem simulates the situation where Jumong issues commands and implements an algorithm to handle them efficiently. I will explain in detail how to solve the problem and implement the code. Problem Description Jumong gives &hellip; <a href=\"https:\/\/atmokpo.com\/w\/33910\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;C# Coding Test Course, Jumong&#8217;s Command&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[90],"tags":[],"class_list":["post-33910","post","type-post","status-publish","format-standard","hentry","category-c-coding-test-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>C# Coding Test Course, Jumong&#039;s Command - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/atmokpo.com\/w\/33910\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"C# Coding Test Course, Jumong&#039;s Command - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"Hello! In this post, we will solve a coding test problem using the C# language. The topic is &#8216;Jumong&#8217;s Command&#8217;. This problem simulates the situation where Jumong issues commands and implements an algorithm to handle them efficiently. I will explain in detail how to solve the problem and implement the code. Problem Description Jumong gives &hellip; \ub354 \ubcf4\uae30 &quot;C# Coding Test Course, Jumong&#8217;s Command&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/33910\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:21:53+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T10:55:05+00:00\" \/>\n<meta name=\"author\" content=\"root\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:site\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:label1\" content=\"\uae00\uc4f4\uc774\" \/>\n\t<meta name=\"twitter:data1\" content=\"root\" \/>\n\t<meta name=\"twitter:label2\" content=\"\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04\" \/>\n\t<meta name=\"twitter:data2\" content=\"4\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/atmokpo.com\/w\/33910\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/33910\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"C# Coding Test Course, Jumong&#8217;s Command\",\"datePublished\":\"2024-11-01T09:21:53+00:00\",\"dateModified\":\"2024-11-01T10:55:05+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/33910\/\"},\"wordCount\":472,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"C# Coding Test Tutorials\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/33910\/\",\"url\":\"https:\/\/atmokpo.com\/w\/33910\/\",\"name\":\"C# Coding Test Course, Jumong's Command - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:21:53+00:00\",\"dateModified\":\"2024-11-01T10:55:05+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/33910\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/33910\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/33910\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"C# Coding Test Course, Jumong&#8217;s Command\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/atmokpo.com\/w\/#website\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/atmokpo.com\/w\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ko-KR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"contentUrl\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"width\":400,\"height\":400,\"caption\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\"},\"image\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/bebubo4\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\",\"name\":\"root\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"caption\":\"root\"},\"sameAs\":[\"http:\/\/atmokpo.com\/w\"],\"url\":\"https:\/\/atmokpo.com\/w\/author\/root\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"C# Coding Test Course, Jumong's Command - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/atmokpo.com\/w\/33910\/","og_locale":"ko_KR","og_type":"article","og_title":"C# Coding Test Course, Jumong's Command - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"Hello! In this post, we will solve a coding test problem using the C# language. The topic is &#8216;Jumong&#8217;s Command&#8217;. This problem simulates the situation where Jumong issues commands and implements an algorithm to handle them efficiently. I will explain in detail how to solve the problem and implement the code. Problem Description Jumong gives &hellip; \ub354 \ubcf4\uae30 \"C# Coding Test Course, Jumong&#8217;s Command\"","og_url":"https:\/\/atmokpo.com\/w\/33910\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:21:53+00:00","article_modified_time":"2024-11-01T10:55:05+00:00","author":"root","twitter_card":"summary_large_image","twitter_creator":"@bebubo4","twitter_site":"@bebubo4","twitter_misc":{"\uae00\uc4f4\uc774":"root","\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04":"4\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/atmokpo.com\/w\/33910\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/33910\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"C# Coding Test Course, Jumong&#8217;s Command","datePublished":"2024-11-01T09:21:53+00:00","dateModified":"2024-11-01T10:55:05+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/33910\/"},"wordCount":472,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["C# Coding Test Tutorials"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/33910\/","url":"https:\/\/atmokpo.com\/w\/33910\/","name":"C# Coding Test Course, Jumong's Command - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:21:53+00:00","dateModified":"2024-11-01T10:55:05+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/33910\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/33910\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/33910\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"C# Coding Test Course, Jumong&#8217;s Command"}]},{"@type":"WebSite","@id":"https:\/\/atmokpo.com\/w\/#website","url":"https:\/\/atmokpo.com\/w\/","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","description":"","publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/atmokpo.com\/w\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ko-KR"},{"@type":"Organization","@id":"https:\/\/atmokpo.com\/w\/#organization","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","url":"https:\/\/atmokpo.com\/w\/","logo":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/","url":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","contentUrl":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","width":400,"height":400,"caption":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8"},"image":{"@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/bebubo4"]},{"@type":"Person","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7","name":"root","image":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","caption":"root"},"sameAs":["http:\/\/atmokpo.com\/w"],"url":"https:\/\/atmokpo.com\/w\/author\/root\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/33910","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/comments?post=33910"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/33910\/revisions"}],"predecessor-version":[{"id":33911,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/33910\/revisions\/33911"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=33910"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=33910"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=33910"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}