{"id":33754,"date":"2024-11-01T09:19:59","date_gmt":"2024-11-01T09:19:59","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=33754"},"modified":"2024-11-01T11:46:49","modified_gmt":"2024-11-01T11:46:49","slug":"python-coding-test-course-jumongs-command","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/33754\/","title":{"rendered":"Python Coding Test Course, Jumong&#8217;s Command"},"content":{"rendered":"<p><body><\/p>\n<h2>1. Problem Overview<\/h2>\n<p>\n        This coding test problem is to implement the given conditions based on the orders that Jumong gave to his soldiers. The problem is as follows.\n    <\/p>\n<h3>Problem Description<\/h3>\n<p>\n        Jumong gives each soldier <code>N<\/code> commands. Each command instructs them to move in a specific direction.<br \/>\n        The soldiers receive and execute these commands. However, Jumong made a mistake during the command process and decided to ignore some commands.<br \/>\n        Now, you need to write a program that calculates the final position based on the executed commands by the soldiers.\n    <\/p>\n<h3>Format of Commands<\/h3>\n<ul>\n<li>The commands are given as a list of strings: <code>[\"U\", \"D\", \"L\", \"R\"]<\/code>.<\/li>\n<li>&#8220;U&#8221; means to move up by one step, &#8220;D&#8221; means to move down by one step, &#8220;L&#8221; means to move left by one step, and &#8220;R&#8221; means to move right by one step.<\/li>\n<li>The number of commands is <code>1 \u2264 N \u2264 1000<\/code>.<\/li>\n<\/ul>\n<h3>Input<\/h3>\n<p>\n        The first line contains the number of commands <code>N<\/code>,<br \/>\n        and the next <code>N<\/code> lines contain each command.\n    <\/p>\n<h3>Output<\/h3>\n<p>\n        Output the coordinates of the final position <code>(x, y)<\/code> as integers.<br \/>\n        The initial position is <code>(0, 0)<\/code>.\n    <\/p>\n<h2>2. Problem Solving Process<\/h2>\n<h3>2.1. Understanding the Problem<\/h3>\n<p>\n        To solve the problem, we need to implement the movement according to each command following specific rules.<br \/>\n        The list of commands will be analyzed, and the coordinates will be updated according to each command.\n    <\/p>\n<h3>2.2. Data Structure Design<\/h3>\n<p>\n        We use the <code>(x, y)<\/code> coordinates to store the final position.<br \/>\n        It is initialized with <code>x = 0, y = 0<\/code>.\n    <\/p>\n<h3>2.3. Algorithm Design<\/h3>\n<p>\n        We will read each command line by line and move in the corresponding direction.<br \/>\n        In other words, the coordinates will be updated as follows based on each command:\n    <\/p>\n<ul>\n<li><code>\"U\"<\/code>: <code>y += 1<\/code><\/li>\n<li><code>\"D\"<\/code>: <code>y -= 1<\/code><\/li>\n<li><code>\"L\"<\/code>: <code>x -= 1<\/code><\/li>\n<li><code>\"R\"<\/code>: <code>x += 1<\/code><\/li>\n<\/ul>\n<h3>2.4. Final Code Implementation<\/h3>\n<pre><code>def final_position(commands):\n    x, y = 0, 0  # Initial position\n\n    for command in commands:\n        if command == \"U\":\n            y += 1\n        elif command == \"D\":\n            y -= 1\n        elif command == \"L\":\n            x -= 1\n        elif command == \"R\":\n            x += 1\n\n    return (x, y)\n\n# Example input\nN = int(input(\"Enter the number of commands: \"))\ncommands = [input().strip() for _ in range(N)]\n# Output final position\nprint(final_position(commands))<\/code><\/pre>\n<h2>3. Examples and Tests<\/h2>\n<h3>3.1. Test Cases<\/h3>\n<p>\n        For example, if the following input is given:\n    <\/p>\n<pre><code>5\n    R\n    R\n    U\n    D\n    L<\/code><\/pre>\n<p>\n        When processing the above commands, the final position will be <code>(1, 0)<\/code>.\n    <\/p>\n<h2>4. Conclusion<\/h2>\n<p>\n        In this process, we implemented an algorithm to calculate the final position of the soldiers based on Jumong&#8217;s commands.<br \/>\n        We solved the problem through coordinate updates according to each command.<br \/>\n        This simple problem helps us understand the basics of data structures and algorithm application.\n    <\/p>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. Problem Overview This coding test problem is to implement the given conditions based on the orders that Jumong gave to his soldiers. The problem is as follows. Problem Description Jumong gives each soldier N commands. Each command instructs them to move in a specific direction. The soldiers receive and execute these commands. However, Jumong &hellip; <a href=\"https:\/\/atmokpo.com\/w\/33754\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;Python 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":[145],"tags":[],"class_list":["post-33754","post","type-post","status-publish","format-standard","hentry","category-python-coding-test"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python 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\/33754\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Coding Test Course, Jumong&#039;s Command - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"1. Problem Overview This coding test problem is to implement the given conditions based on the orders that Jumong gave to his soldiers. The problem is as follows. Problem Description Jumong gives each soldier N commands. Each command instructs them to move in a specific direction. The soldiers receive and execute these commands. However, Jumong &hellip; \ub354 \ubcf4\uae30 &quot;Python Coding Test Course, Jumong&#8217;s Command&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/33754\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:19:59+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T11:46:49+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=\"2\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/atmokpo.com\/w\/33754\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/33754\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"Python Coding Test Course, Jumong&#8217;s Command\",\"datePublished\":\"2024-11-01T09:19:59+00:00\",\"dateModified\":\"2024-11-01T11:46:49+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/33754\/\"},\"wordCount\":331,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"Python Coding Test\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/33754\/\",\"url\":\"https:\/\/atmokpo.com\/w\/33754\/\",\"name\":\"Python Coding Test Course, Jumong's Command - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:19:59+00:00\",\"dateModified\":\"2024-11-01T11:46:49+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/33754\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/33754\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/33754\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python 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":"Python 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\/33754\/","og_locale":"ko_KR","og_type":"article","og_title":"Python Coding Test Course, Jumong's Command - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"1. Problem Overview This coding test problem is to implement the given conditions based on the orders that Jumong gave to his soldiers. The problem is as follows. Problem Description Jumong gives each soldier N commands. Each command instructs them to move in a specific direction. The soldiers receive and execute these commands. However, Jumong &hellip; \ub354 \ubcf4\uae30 \"Python Coding Test Course, Jumong&#8217;s Command\"","og_url":"https:\/\/atmokpo.com\/w\/33754\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:19:59+00:00","article_modified_time":"2024-11-01T11:46:49+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":"2\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/atmokpo.com\/w\/33754\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/33754\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"Python Coding Test Course, Jumong&#8217;s Command","datePublished":"2024-11-01T09:19:59+00:00","dateModified":"2024-11-01T11:46:49+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/33754\/"},"wordCount":331,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["Python Coding Test"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/33754\/","url":"https:\/\/atmokpo.com\/w\/33754\/","name":"Python Coding Test Course, Jumong's Command - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:19:59+00:00","dateModified":"2024-11-01T11:46:49+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/33754\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/33754\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/33754\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"Python 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\/33754","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=33754"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/33754\/revisions"}],"predecessor-version":[{"id":33755,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/33754\/revisions\/33755"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=33754"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=33754"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=33754"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}