{"id":35152,"date":"2024-11-01T09:36:08","date_gmt":"2024-11-01T09:36:08","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=35152"},"modified":"2024-11-01T09:37:41","modified_gmt":"2024-11-01T09:37:41","slug":"%ec%bd%94%ed%8b%80%eb%a6%b0-coding-test-course-card-game","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/35152\/","title":{"rendered":"Coding Test Course, Card Game"},"content":{"rendered":"<p><body><\/p>\n<p>\n        In this article, we will address &#8216;card game&#8217; related problems through a Kotlin-based algorithm problem-solving course.<br \/>\n        We will explain in detail the theories, code examples, and various approaches necessary to solve algorithm problems.\n    <\/p>\n<h2>Problem Description<\/h2>\n<p>\n        A card game is a game that starts with two players each holding 5 cards.<br \/>\n        Each player calculates their score based on the numbers on the cards.<br \/>\n        We will describe a game where the scores of the two players are compared to determine the winner.\n    <\/p>\n<h3>Problem Definition<\/h3>\n<p>\n        There are two players, A and B. Each player A and B has 5 cards.<br \/>\n        The score of the cards is based on their numbers. You need to write a program to determine which player is the winner by comparing the total scores of the two players.\n    <\/p>\n<h3>Input<\/h3>\n<ul>\n<li>The first line contains 5 cards of player A separated by spaces.<\/li>\n<li>The second line contains 5 cards of player B separated by spaces.<\/li>\n<\/ul>\n<h3>Output<\/h3>\n<ul>\n<li>Print the name of the player with the higher total score.<\/li>\n<li>If the scores are the same, print &#8220;Draw&#8221;.<\/li>\n<\/ul>\n<h2>Example<\/h2>\n<pre>\n    Input:\n    3 5 2 1 4\n    6 5 4 3 2\n\n    Output:\n    B\n    <\/pre>\n<h2>Approach to the Problem<\/h2>\n<p>\n        To solve the problem, we go through the following steps:\n    <\/p>\n<ol>\n<li>Input the cards of players A and B as lists.<\/li>\n<li>Calculate the scores for each player.<\/li>\n<li>Compare the scores to determine the winner.<\/li>\n<\/ol>\n<h2>Code Implementation<\/h2>\n<p>\n        Below is the code written in Kotlin.\n    <\/p>\n<pre><code>fun main() {\n        \/\/ Read input.\n        val aCards = readLine()!!.split(\" \").map { it.toInt() }\n        val bCards = readLine()!!.split(\" \").map { it.toInt() }\n\n        \/\/ Calculate scores.\n        val aScore = aCards.sum()\n        val bScore = bCards.sum()\n\n        \/\/ Determine the winner.\n        when {\n            aScore &gt; bScore -&gt; println(\"A\")\n            aScore &lt; bScore -&gt; println(\"B\")\n            else -&gt; println(\"Draw\")\n        }\n    }<\/code><\/pre>\n<h2>Code Analysis<\/h2>\n<p>\n        The above code performs the following functions:\n    <\/p>\n<ul>\n<li><code>readLine()<\/code> reads the two lines of input from the user and splits them into a list of integers based on spaces.<\/li>\n<li>Each player&#8217;s scores are calculated using the <code>sum()<\/code> method.<\/li>\n<li>The scores are compared using the <code>when<\/code> statement, and the name of the player with the higher score is printed.<\/li>\n<\/ul>\n<h2>Testing and Validation<\/h2>\n<p>\n        It is essential to test the code in various situations to validate that the correct output is produced based on the input.<br \/>\n        You should consider various test cases, including edge cases such as when all cards of player A are zero.\n    <\/p>\n<h2>Conclusion<\/h2>\n<p>\n        In this lecture, we explored the process of solving a simple card game problem using Kotlin.<br \/>\n        Understanding the problem, designing the algorithm, and implementing it in code are vital steps in solving algorithm problems,<br \/>\n        which can be improved through practice with various approaches.<br \/>\n        Keep practicing consistently and solving various problems to enhance your coding skills.\n    <\/p>\n<h2>Additional Practice Problems<\/h2>\n<p>\n        Try solving the following additional problems:\n    <\/p>\n<ul>\n<li>Write a program to calculate how the scoring system changes if each player holds 7 cards.<\/li>\n<li>Implement a program to add simple rules affecting the final score through card betting for each player.<\/li>\n<\/ul>\n<p>\n        Consistent practice is essential. Best wishes for successful coding test preparation!\n    <\/p>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article, we will address &#8216;card game&#8217; related problems through a Kotlin-based algorithm problem-solving course. We will explain in detail the theories, code examples, and various approaches necessary to solve algorithm problems. Problem Description A card game is a game that starts with two players each holding 5 cards. Each player calculates their score &hellip; <a href=\"https:\/\/atmokpo.com\/w\/35152\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;Coding Test Course, Card Game&#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":[106],"tags":[],"class_list":["post-35152","post","type-post","status-publish","format-standard","hentry","category----en"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Coding Test Course, Card Game - \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\/35152\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Coding Test Course, Card Game - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"In this article, we will address &#8216;card game&#8217; related problems through a Kotlin-based algorithm problem-solving course. We will explain in detail the theories, code examples, and various approaches necessary to solve algorithm problems. Problem Description A card game is a game that starts with two players each holding 5 cards. Each player calculates their score &hellip; \ub354 \ubcf4\uae30 &quot;Coding Test Course, Card Game&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/35152\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:36:08+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T09:37:41+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\/35152\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/35152\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"Coding Test Course, Card Game\",\"datePublished\":\"2024-11-01T09:36:08+00:00\",\"dateModified\":\"2024-11-01T09:37:41+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/35152\/\"},\"wordCount\":431,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"Kotlin coding test\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/35152\/\",\"url\":\"https:\/\/atmokpo.com\/w\/35152\/\",\"name\":\"Coding Test Course, Card Game - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:36:08+00:00\",\"dateModified\":\"2024-11-01T09:37:41+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/35152\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/35152\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/35152\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Coding Test Course, Card Game\"}]},{\"@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":"Coding Test Course, Card Game - \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\/35152\/","og_locale":"ko_KR","og_type":"article","og_title":"Coding Test Course, Card Game - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"In this article, we will address &#8216;card game&#8217; related problems through a Kotlin-based algorithm problem-solving course. We will explain in detail the theories, code examples, and various approaches necessary to solve algorithm problems. Problem Description A card game is a game that starts with two players each holding 5 cards. Each player calculates their score &hellip; \ub354 \ubcf4\uae30 \"Coding Test Course, Card Game\"","og_url":"https:\/\/atmokpo.com\/w\/35152\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:36:08+00:00","article_modified_time":"2024-11-01T09:37:41+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\/35152\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/35152\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"Coding Test Course, Card Game","datePublished":"2024-11-01T09:36:08+00:00","dateModified":"2024-11-01T09:37:41+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/35152\/"},"wordCount":431,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["Kotlin coding test"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/35152\/","url":"https:\/\/atmokpo.com\/w\/35152\/","name":"Coding Test Course, Card Game - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:36:08+00:00","dateModified":"2024-11-01T09:37:41+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/35152\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/35152\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/35152\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"Coding Test Course, Card Game"}]},{"@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\/35152","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=35152"}],"version-history":[{"count":2,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/35152\/revisions"}],"predecessor-version":[{"id":35304,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/35152\/revisions\/35304"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=35152"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=35152"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=35152"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}