{"id":35020,"date":"2024-11-01T09:34:42","date_gmt":"2024-11-01T09:34:42","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=35020"},"modified":"2024-11-01T12:51:23","modified_gmt":"2024-11-01T12:51:23","slug":"%ec%a0%84%eb%ac%b8%ea%b0%80-%ec%bd%94%ed%8b%80%eb%a6%b0-%ec%bd%94%eb%94%a9-%ed%85%8c%ec%8a%a4%ed%8a%b8-%ea%b0%95%ec%a2%8c-%eb%b8%94%eb%a3%a8%eb%a0%88%ec%9d%b4-%eb%a7%8c%eb%93%a4%ea%b8%b0","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/35020\/","title":{"rendered":"Advanced Kotlin coding test course, creating Blu-rays"},"content":{"rendered":"<p><body><\/p>\n<h2>Problem Description<\/h2>\n<p>\n        Blu-ray discs are media that can store large amounts of data, including movies, music, and data files.<br \/>\n        Recently, a company wants to develop an algorithm to efficiently store data on Blu-ray discs.<br \/>\n        Accordingly, each Blu-ray disc has a specific capacity, and multiple files need to be stored on this disc.<br \/>\n        Given the sizes of the data to be stored and the maximum capacity of each disc, the problem is to determine the minimum number of discs required.\n    <\/p>\n<h2>Input<\/h2>\n<p>\n        The first line contains an integer array including the number of data files <code>N<\/code> (1 \u2264 N \u2264 1000) and the size of each file <code>S_i<\/code> (1 \u2264 S_i \u2264 10^6).<br \/>\n        The second line gives the maximum capacity of each Blu-ray disc <code>C<\/code> (1 \u2264 C \u2264 10^6).\n    <\/p>\n<h2>Output<\/h2>\n<p>\n        Output the minimum number of discs.\n    <\/p>\n<h2>Example<\/h2>\n<h3>Input<\/h3>\n<pre>\n    5\n    2 4 3 6 5\n    8\n    <\/pre>\n<h3>Output<\/h3>\n<pre>\n    2\n    <\/pre>\n<h2>Approach to the Problem<\/h2>\n<p>\n        To solve this problem, the following approach is needed:\n    <\/p>\n<ol>\n<li>Sort the sizes of each file and save them to the Blu-ray disc, starting with the largest file.<\/li>\n<li>When storing files on the Blu-ray disc, ensure that adding the current file does not exceed the capacity.<\/li>\n<li>If there is insufficient capacity to add a file to the current disc, a new disc must be used.<\/li>\n<li>Repeat this process until all files are stored to calculate the total number of discs.<\/li>\n<\/ol>\n<h2>Code Implementation<\/h2>\n<p>\n        Below is the code written in Kotlin:\n    <\/p>\n<pre><code>\nfun minNumberOfDisks(fileSizes: List<int>, capacity: Int): Int {\n    val sortedFiles = fileSizes.sortedDescending() \/\/ Sort file sizes in descending order\n    var diskCount = 0\n    var currentDiskUsage = 0\n\n    for (fileSize in sortedFiles) {\n        if (currentDiskUsage + fileSize &gt; capacity) {\n            diskCount++ \/\/ Add new disc\n            currentDiskUsage = fileSize \/\/ Reset disk with current file\n        } else {\n            currentDiskUsage += fileSize \/\/ Add file to current disc\n        }\n    }\n\n    \/\/ Add 1 for the last disc as well\n    return diskCount + if (currentDiskUsage &gt; 0) 1 else 0\n}\n\nfun main() {\n    val fileSizes = listOf(2, 4, 3, 6, 5) \/\/ Input file sizes\n    val capacity = 8 \/\/ Maximum capacity of the Blu-ray disc\n    println(minNumberOfDisks(fileSizes, capacity)) \/\/ Output result\n}\n    <\/int><\/code><\/pre>\n<h2>Code Explanation<\/h2>\n<p>\n        &#8211; The <code>minNumberOfDisks<\/code> function takes a list of file sizes and the disc capacity as input.<br \/>\n        &#8211; After sorting the file sizes in descending order, it determines the disc to add each file.<br \/>\n        &#8211; If the current disk usage exceeds the capacity, a new disc is added, and the file usage is reset to the current file.<br \/>\n        &#8211; After processing all files, the total number of discs is returned.<br \/>\n        &#8211; The <code>main<\/code> function verifies the functionality through an example input.\n    <\/p>\n<h2>Conclusion<\/h2>\n<p>\n        This problem requires an overall understanding of efficient disc management and storage space utilization.<br \/>\n        The problem of determining the minimum number of discs required to store all files can be applied in various fields.<br \/>\n        Solving algorithmic problems and considering various situations during optimization can enhance programming skills.\n    <\/p>\n<h2>Additional Challenges<\/h2>\n<p>\n        &#8211; When the number of Blu-ray discs is fixed, explore ways to optimize the file placement.<br \/>\n        &#8211; Implement an algorithm that can handle various capacities of Blu-ray discs.\n    <\/p>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Problem Description Blu-ray discs are media that can store large amounts of data, including movies, music, and data files. Recently, a company wants to develop an algorithm to efficiently store data on Blu-ray discs. Accordingly, each Blu-ray disc has a specific capacity, and multiple files need to be stored on this disc. Given the sizes &hellip; <a href=\"https:\/\/atmokpo.com\/w\/35020\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;Advanced Kotlin coding test course, creating Blu-rays&#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-35020","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>Advanced Kotlin coding test course, creating Blu-rays - \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\/35020\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Advanced Kotlin coding test course, creating Blu-rays - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"Problem Description Blu-ray discs are media that can store large amounts of data, including movies, music, and data files. Recently, a company wants to develop an algorithm to efficiently store data on Blu-ray discs. Accordingly, each Blu-ray disc has a specific capacity, and multiple files need to be stored on this disc. Given the sizes &hellip; \ub354 \ubcf4\uae30 &quot;Advanced Kotlin coding test course, creating Blu-rays&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/35020\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:34:42+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T12:51:23+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\/35020\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/35020\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"Advanced Kotlin coding test course, creating Blu-rays\",\"datePublished\":\"2024-11-01T09:34:42+00:00\",\"dateModified\":\"2024-11-01T12:51:23+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/35020\/\"},\"wordCount\":381,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"Kotlin coding test\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/35020\/\",\"url\":\"https:\/\/atmokpo.com\/w\/35020\/\",\"name\":\"Advanced Kotlin coding test course, creating Blu-rays - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:34:42+00:00\",\"dateModified\":\"2024-11-01T12:51:23+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/35020\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/35020\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/35020\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Advanced Kotlin coding test course, creating Blu-rays\"}]},{\"@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":"Advanced Kotlin coding test course, creating Blu-rays - \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\/35020\/","og_locale":"ko_KR","og_type":"article","og_title":"Advanced Kotlin coding test course, creating Blu-rays - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"Problem Description Blu-ray discs are media that can store large amounts of data, including movies, music, and data files. Recently, a company wants to develop an algorithm to efficiently store data on Blu-ray discs. Accordingly, each Blu-ray disc has a specific capacity, and multiple files need to be stored on this disc. Given the sizes &hellip; \ub354 \ubcf4\uae30 \"Advanced Kotlin coding test course, creating Blu-rays\"","og_url":"https:\/\/atmokpo.com\/w\/35020\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:34:42+00:00","article_modified_time":"2024-11-01T12:51:23+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\/35020\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/35020\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"Advanced Kotlin coding test course, creating Blu-rays","datePublished":"2024-11-01T09:34:42+00:00","dateModified":"2024-11-01T12:51:23+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/35020\/"},"wordCount":381,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["Kotlin coding test"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/35020\/","url":"https:\/\/atmokpo.com\/w\/35020\/","name":"Advanced Kotlin coding test course, creating Blu-rays - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:34:42+00:00","dateModified":"2024-11-01T12:51:23+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/35020\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/35020\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/35020\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"Advanced Kotlin coding test course, creating Blu-rays"}]},{"@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\/35020","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=35020"}],"version-history":[{"count":2,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/35020\/revisions"}],"predecessor-version":[{"id":38106,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/35020\/revisions\/38106"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=35020"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=35020"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=35020"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}