<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>TraceofLight (EN)</title><description>게임 개발, 그래픽스 프로그래밍, 데이터베이스 엔지니어링을 기록하는 TraceofLight의 기술 아카이브입니다.</description><link>https://www.traceoflight.dev/</link><language>en</language><atom:link href="https://www.traceoflight.dev/en/rss.xml" rel="self" type="application/rss+xml"/><lastBuildDate>Sun, 10 May 2026 15:37:52 GMT</lastBuildDate><item><title>Summary of what was learned at Unity Roadshow 2026</title><link>https://www.traceoflight.dev/en/blog/unity-roadshow-2026/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/unity-roadshow-2026/</guid><description>A brief record of what I learned at the Unity Roadshow</description><pubDate>Sun, 19 Apr 2026 13:17:51 GMT</pubDate><content:encoded>&lt;h2&gt;Memory Prerequisites&lt;/h2&gt;
&lt;h3&gt;Basic Content&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;We use Virtual Memory (VM) and do not directly control physical memory.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;VM is composed of pages, which may vary depending on the OS.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Windows / Linux 4kb&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;iOS, MacOS, Android 16kb&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A physical memory frame exists corresponding to the page.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Virtual memory is merged into physical memory depending on the level of memory pressure.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Page Fault&lt;/h3&gt;
&lt;p&gt;A Page Fault occurs when a page that has not been loaded into physical memory is needed.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Clean Page: A page whose original data has not changed; it can be released by the OS at any time and is easy to reclaim.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Dirty Page: A page containing information newly written or modified by an application; it cannot be immediately removed from memory.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;Memory Footprint&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;An indicator representing actual memory pressure, resulting from the sum of the total dirty page sizes.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;Memory Footprint != Physical memory usage, Resident memory usage&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Memory Management (Windows vs Linux)&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Reserved: Does not use physical memory Allocate only virtual memory without reserving&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Commit: Allocates physical frames equivalent to the actual virtual memory&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Decommit: Releases physical frames while maintaining reserved space&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;Windows: Provides explicit APIs (virtual alloc, virtual free)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;UNIX Like: No explicit separation between reservation and commit&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;mmap calls implicitly reserve memory&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Lazy commit occurs when accessing pages immediately&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;No explicit API; decommit operates via hints&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;The OS decides when to reclaim pages&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;h2&gt;Handling in Unity GC&lt;/h2&gt;
&lt;h3&gt;Managed Heap&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;All C# memory allocation takes place here&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Managed by the Garbage Collector&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Indicated as GC.Alloc in Unity Profiler&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Garbage Collector&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Periodically collects objects from the Heap that do not have valid references&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Performing GC does not reduce total virtual memory usage&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The space occupied by collected objects is also considered Dirty by the OS&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Segment&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Defined as a collection of consecutive pages&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Managed Heap uses Segments instead of Raw Pages&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Multiple objects can be allocated to a single Segment&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;After allocating and releasing them, there are internally unused instances, but they are marked as RAM usage (because they are dirty)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In most cases, there are no issues and they are reused soon&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Cases where they remain empty for too long waste resident memory, so Unity GC handles them intermittently&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;What Unity GC Does&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Uses remapping strategies&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;After multiple GC runs, Old Empty Segments are dropped, and New Segments of the same size are allocated&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Windows Remap Strategy: Decommits without releasing Segments (because it is an explicit process)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;UNIX-Like Remap Strategy: Remaps via munmap &amp;amp; mmap (High cache hit rate due to Hot Page effect)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;This has the advantage of reducing resident memory&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;GC.Collect Should Not Be Run Multiple Times Reasons&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Do not force segment releases&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Collect is expensive and can cause app freezing&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The intention itself is to decommit segments that have been empty for a long time&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Decommitting segments that are briefly empty is contrary to the intention&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Forced decommitting does not improve performance and only incurs CPU costs&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Causes a situation where segments that will be reused in the next frame are also decommitted&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;VM usage in Managed Heap only increases and never decreases&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The Heap only increases and never decreases&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The inherent characteristics of Boehm GC&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;There is no reason to trim virtual memory allocations&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Large virtual memory != Large physical memory usage&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Segments are reused anyway&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Game objects are frequently created and destroyed every frame&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Shrinking segments every time an object is destroyed only wastes CPU performance&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Unity Boehm GC&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Unity&apos;s Incremental Boehm GC is a Conservative GC&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;This supports the task of converting C# code written in the past into C++ It came to be primarily used with the provision of IL2CPP.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;While IL2CPP enabled support for various environments, it appears that the open-source GC Boehm GC was used because, unlike C#, memory GC was not automated.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Focusing on stability rather than performance, it considers all values that look &amp;quot;like&amp;quot; pointers as references.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Object locations are not changed during GC -&amp;gt; No compaction, and vulnerable to memory fragmentation.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;About Compaction&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Memory compression is advantageous for resolving memory fragmentation. It clears out all unused space to rearrange it.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Impossible in conservative GCs because accurate reference information is required.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Moving object locations incurs a cost (Stop The World + actual movement).&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;h3&gt;CoreCLR GC&lt;/h3&gt;
&lt;p&gt;CoreCLR GC is a Precise GC that accurately knows which values in the memory stack and registers are references.&lt;/p&gt;
&lt;p&gt;And .NET uses CoreCLR as its core engine (CLR: Common Language Runtime)&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Features supported by CoreCLR&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;CoreCLR GC&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;JIT Compiler&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Exception Control&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;misc...&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;p&gt;This CoreCLR GC (hereinafter .NET GC) uses a generation-based memory management method&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Manages the Heap by dividing it into 3 generations&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Generation 0: Primarily consists of newly created objects; frequent and fast GC occurs (most objects die here)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Generation 1: Acts as a buffer for objects that survived Generation 0 to move to&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Generation 2: Resides for heavy objects that have survived for a long time; cleaning this area is costly for the GC&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;LOH: Very large objects are placed in this space&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Fragmentation can be reduced as memory compaction is handled during the promotion process&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;In the case of LOH, compaction was not performed in the past because the STW (Stop-the-World) lengthens, but it is said that it is now handled as an explicit option.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;The Value of the Transition?&lt;/h3&gt;
&lt;p&gt;Basically, Unity to .NET I mentioned that the change in GC is a side effect of the transition, not the primary one. However, if we look for its value...&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Memory fragmentation is reduced because Compation is supported.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;GC costs can be made predictable.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
</content:encoded></item><item><title>A quick note about container environments</title><link>https://www.traceoflight.dev/en/blog/difference-btw-container-vm/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/difference-btw-container-vm/</guid><description>Record the differences between containers and VMs and other lessons learned</description><pubDate>Thu, 02 Apr 2026 06:58:20 GMT</pubDate><content:encoded>&lt;h3&gt;&lt;strong&gt;How Containers Work&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Share the host OS&apos;s kernel but isolate it like a process&lt;/p&gt;
&lt;h3&gt;&lt;strong&gt;What if the kernel is incompatible?&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Of course it won&apos;t run, but the reason why it can run on MAC, WINDOW, etc. is because it adds a whole VM layer&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Why docker desktop installation on windows tells you to install wsl2. It seems to be because you need to install MS&apos;s Linux VM to make that layer-based container work.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Even if the issue is with the kernel version, it can still crash (trying to use features that don&apos;t exist due to version differences, etc)&lt;/p&gt;
&lt;h3&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;.&lt;/h3&gt;
&lt;p&gt;Kernel types must match, feature support must not be an issue, and CPU architectures must match for containers to run.&lt;/p&gt;
&lt;h3&gt;&lt;strong&gt;VM&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Standalone with hypervisor, separate kernel. There is bare-metal / hosted, what we use is mostly hosted, there is performance loss because hypervisor is on top of OS&lt;/p&gt;
&lt;h3&gt;&lt;strong&gt;Volume Binding&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Used to preserve data persistence, handled by mounting a specific directory on the host machine. On Linux native, it writes directly to the VFS, on other OSes it burns the internal virtual network and can be relatively slow.&lt;/p&gt;
&lt;h3&gt;&lt;strong&gt;Why Windows ignores chmod&lt;/strong&gt;.&lt;/h3&gt;
&lt;p&gt;Windows uses ACLs (Access Control Lists) to manage permissions and doesn&apos;t understand how chmod works.&lt;/p&gt;
</content:encoded></item><item><title>Testimonials from the Crafton Jungle Gametech Lab</title><link>https://www.traceoflight.dev/en/blog/jungle-gametech-lab-review/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/jungle-gametech-lab-review/</guid><description>My story of completing the second year of the Crafton Jungle Gametech Lab</description><pubDate>Thu, 26 Mar 2026 18:02:12 GMT</pubDate><content:encoded>&lt;h2&gt;enters&lt;/h2&gt;
&lt;p&gt;Since I&apos;ve been putting my real life on hold for about half a year since completing the program, I&apos;ve been a little confused about when to write this review.&lt;/p&gt;
&lt;p&gt;However, I think I should write it down before my memory gets a little fuzzy, so here it is.&lt;/p&gt;
&lt;p&gt;I&apos;ve also included a replay of the presentation in the media above, in case anyone reading this is still thinking about it.&lt;/p&gt;
&lt;h2&gt;Mouth and mouth agony&lt;/h2&gt;
&lt;p&gt;First of all, I didn&apos;t know what I wanted to do right away. I had a lot of plans for what I would be doing in the second half of 2025.&lt;/p&gt;
&lt;p&gt;However, I chose to enroll because I realized that most of them hadn&apos;t worked out, and I felt like I had a pretty good option.&lt;/p&gt;
&lt;br /&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;https://traceoflight.dev/media/image/240d3d9a-5133-45d9-a584-df6d6f8dc511-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;br /&gt;
&lt;p&gt;I&apos;ve had a few interviews that didn&apos;t go well, so I&apos;ve always wondered how to fill in the gaps in my experience.&lt;/p&gt;
&lt;p&gt;I had never touched a commercial real-time 3D engine before, so I couldn&apos;t explain the overall functionality, let alone the internal logic.&lt;/p&gt;
&lt;p&gt;So, when I stood in front of the interviewer with all the knowledge I had gained from fighting AI, I could only give a superficial explanation.&lt;/p&gt;
&lt;p&gt;Looking back on it now, I feel very embarrassed to think about what the interviewer must have thought while listening to those answers.&lt;/p&gt;
&lt;br /&gt;
&lt;p&gt;At the time, I considered the risks of taking the course to be twofold.&lt;/p&gt;
&lt;p&gt;I had no idea what the course would be like or what the outcome would be, as I had only one previous ride and hadn&apos;t even completed it.&lt;/p&gt;
&lt;p&gt;Another risk was that the second semester was scheduled to take place in the second half of the year, and the game companies I was interested in usually recruit interns in the second half of the year.&lt;/p&gt;
&lt;br /&gt;
&lt;p&gt;After weighing the options, I decided on pre-med. Now that I think about it, I think the information session I went to had quite an impact.&lt;/p&gt;
&lt;p&gt;There was a game lab in the jungle course, so I was wondering if I should take the course, and if so, which course I should apply for, but after the information session, my decision was clear.&lt;/p&gt;
&lt;h2&gt;About the course&lt;/h2&gt;
&lt;p&gt;I&apos;m not sure what the outcome of the course will be, but so far I&apos;m very happy with the experience.&lt;/p&gt;
&lt;p&gt;I won&apos;t go into detail about what we do in the course and the situations we encounter because, to quote the coaches, it would &amp;quot;spoil the fun for the junglers&amp;quot;.&lt;/p&gt;
&lt;p&gt;However, I can tell you that TechLab is not an easy process. It&apos;s almost impossible to juggle other tasks, and the lights are rarely turned off in the classroom throughout the course.&lt;/p&gt;
&lt;p&gt;However, it&apos;s safe to say that you&apos;ll gain an impressive amount of experience, knowledge, and understanding of commercial real-time 3D engines.&lt;/p&gt;
&lt;h2&gt;So who should come?&lt;/h2&gt;
&lt;p&gt;It&apos;s probably most intuitive to bring a copy of the presentation.&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;https://traceoflight.dev/media/image/2572851e-3357-4318-803f-1cac3e951f91-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I think people who want to know more about these things should come. You&apos;ll gain a lot of understanding.&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;https://traceoflight.dev/media/image/b21999e7-643c-4d5f-bfbf-f3c801e197f3-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I know I said I wasn&apos;t going to cover this, but people who are curious about some of the graphics and development environments here should consider taking a tech lab.&lt;/p&gt;
&lt;p&gt;After taking the course, you&apos;ll be able to at least recite the lunar calendar and share a simple tiki-taka about them.&lt;/p&gt;
&lt;h2&gt;Final thoughts&lt;/h2&gt;
&lt;p&gt;Now that I&apos;ve finished the course, I&apos;m very happy to have completed it, but there are still many things I need to organize in the future because I experienced so much in such a short period of time.&lt;/p&gt;
&lt;p&gt;However, after digesting all of them, I think I will be a more mature developer.&lt;/p&gt;
&lt;p&gt;There is a lot of talk about downsizing the workforce in the industry due to the development of AI, but I&apos;m going to do what I can.&lt;/p&gt;
&lt;p&gt;There&apos;s also been a lot of talk about growth gaslighting lately, but I&apos;ve definitely seen good things happen to people around me who have continued to grow, so I think we&apos;ll be able to keep the momentum going for a while.&lt;/p&gt;
</content:encoded></item><item><title>Setting Up a Unified Terminal Environment for Windows and macOS</title><link>https://www.traceoflight.dev/en/blog/cross-platform-terminal-setting/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/cross-platform-terminal-setting/</guid><description>A Guide to Setting Up a Cross-Platform Terminal Environment That Works on Both Windows and macOS</description><pubDate>Thu, 26 Mar 2026 12:18:01 GMT</pubDate><content:encoded>&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;br /&gt;
&lt;p&gt;: After recently upgrading my MacBook Air, I realized I needed to reconfigure my setup.&lt;/p&gt;
&lt;p&gt;While I’m satisfied with the performance boost from the M1 to the M5, I found that reconfiguring my existing setup was quite labor-intensive. So, I decided to take this opportunity to document the entire process and standardize it so I can easily set things up again in the future.&lt;/p&gt;
&lt;h3&gt;[2026 Mac Terminal Complete Setup (Ghostty + Starship + AI Coding Environment)](&lt;a href=&quot;https://blog.dnd.ac/settings-mac-terminal-2026/&quot;&gt;https://blog.dnd.ac/settings-mac-terminal-2026/&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;br /&gt;
&lt;p&gt;The document that left the biggest impression on me during this process was the resource linked above. The author had left a script detailing a clean and well-configured environment, which was a huge help.&lt;/p&gt;
&lt;p&gt;To cut to the chase, I was able to build my terminal environment as shown below:&lt;/p&gt;
&lt;br /&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;https://traceoflight.dev/media/image/f0670bf2-9240-4320-ad5e-6367803485d2-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;br /&gt;
&lt;p&gt;Internally, the setup is based on Wezterm + Nushell + LazyVim.&lt;/p&gt;
&lt;p&gt;You can find the complete setup guide at [Github Link](&lt;a href=&quot;https://www.github.com/TraceofLight/global-terminal-settings&quot;&gt;https://www.github.com/TraceofLight/global-terminal-settings&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;), which I designed to allow you to build the same environment on both Windows and macOS.&lt;/p&gt;
&lt;h2&gt;Setting&lt;/h2&gt;
&lt;br /&gt;
&lt;p&gt;Goals The goals for this project were clear:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Use the same terminal environment on both Windows and macOS&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Ensure seamless compatibility with LazyVim-based editors&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Maintain a user experience similar to my existing setup&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Ensure&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;p&gt;ease of use with multiplexer tools like tmux I proceeded with the project to achieve these goals.&lt;/p&gt;
&lt;h2&gt;Process&lt;/h2&gt;
&lt;br /&gt;
&lt;p&gt;First, I had to choose the technology to use. These days, the trend in terminal emulators is toward tools with a GUI capable of GPU-accelerated rendering. The reason these tools are gaining popularity is that they are fast and support customization. Since these features were necessary to build the terminal as described in the link above, I chose Wezterm from among them.&lt;/p&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Terminal Emulator&lt;/p&gt;
&lt;p&gt;Since I needed to provide the same user experience across platforms, I considered Alacritty and Wezterm as the only cross-platform terminal emulators with established ecosystems. I felt that Alacritty, which prioritizes minimalism, lacked extensibility, so I chose Wezterm. The fact that it includes a multiplexer was also a major advantage.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Shell&lt;/p&gt;
&lt;p&gt;Since we needed to ensure a consistent user experience across both platforms, we initially aimed to unify the environment to support Unix commands. As a result, we decided early on to use bash on Windows and zsh on macOS. However, we encountered several issues, and ultimately settled on a unified solution based on Nushell.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;LazyVim&lt;/p&gt;
&lt;p&gt;Actually, I was already using tools in this area, and since they integrated seamlessly across most environments without any issues, this wasn’t difficult. We originally used SpaceVim, but since it had already been [discontinued](&lt;a href=&quot;https://wsdjeg.net/why-spacevim-is-archived/&quot;&gt;https://wsdjeg.net/why-spacevim-is-archived/&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;), we had switched to LazyVim some time ago. Since we primarily use an IDE and treat this as a supplementary tool, the installation process went smoothly.&lt;/p&gt;
&lt;h2&gt;Issues Encountered&lt;/h2&gt;
&lt;p&gt;There were a few issues during this process, both of which were related to the switch to Nushell.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Bash is noticeably slow on Windows&lt;/p&gt;
&lt;p&gt;In fact, upon checking later, this turned out to be an inevitable outcome. I discovered that in a Windows environment, an additional compatibility layer is required to handle POSIX-style operations. I actually considered moving to a WSL2 environment, but ultimately ruled it out because that would be no different from using Linux.&lt;/p&gt;
&lt;p&gt;-&amp;gt; To solve this problem, I decided to adopt nushell. I took into account that it is highly compatible with Unix commands, is designed using Rust (which guarantees a certain level of performance), and allows for the same environment setup on macOS.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The navi plugin does not work in nushell on Windows&lt;/p&gt;
&lt;p&gt;Navi is a plugin used as a cheat sheet for terminal commands. Although we don’t use it very often, it would be problematic if the tool’s functionality didn’t work at all, so we explored various solutions. Ultimately, we forked Navi to resolve the issue and implemented the newly built plugin.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Cause: Even when the user’s shell changes, the internal logic applies bash-based syntax, causing issues when using Nushell&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Solution: Instead of handling that part with shell script commands, I removed internal dependencies on bash by using the Rust HTTP client where wget was required and pwsh where bash would normally be used.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;[Detailed Change Log](&lt;a href=&quot;https://github.com/TraceofLight/navi/tree/fix/nushell-usability&quot;&gt;https://github.com/TraceofLight/navi/tree/fix/nushell-usability&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Developers frequently use the terminal, and it goes without saying that a unified environment makes things easier to use. That’s why JetBrains IDEs, which support cross-platform compatibility and consistent usability, are so valuable. Similarly, if your goal is to maintain a consistent user experience across various environments when using the terminal, adopting this approach seems like a good idea.&lt;/p&gt;
</content:encoded></item><item><title>std::variant &amp;amp; std::visit</title><link>https://www.traceoflight.dev/en/blog/variant-and-visit/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/variant-and-visit/</guid><description>Summary of Variant and Visit, Added in C++17</description><pubDate>Mon, 28 Jul 2025 14:13:37 GMT</pubDate><content:encoded>&lt;h3&gt;Additional Information&lt;/h3&gt;
&lt;p&gt;[Related Documentation](&lt;a href=&quot;https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0088r3.html&quot;&gt;https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0088r3.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;p&gt;The link above contains information about Variant, which was added starting with C++17, and the reasons behind its addition. To put it simply, the discussion revolves around the fact that Boost had been using this functionality for far too long—something that should have been included as std::optional—and the consensus was to stop dragging it out and just add it to the standard as soon as possible.&lt;/p&gt;
&lt;h3&gt;Internal Structure&lt;/h3&gt;
&lt;h4&gt;1. Variant&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Data Buffer
A memory space large enough to store the largest type among those specified as template arguments; it is generally implemented as a union.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Identifier
An index or identifier that indicates which type of object is currently stored in the data buffer. By using this identifier, &lt;code&gt;std::variant&lt;/code&gt; can ensure type safety.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;By having a sufficiently large memory buffer, the &lt;code&gt;variant&lt;/code&gt; type can perform the following actions.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;
	&lt;span class=&quot;hljs-keyword&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;Tracer&lt;/span&gt;
	{
		std::string name;

		&lt;span class=&quot;hljs-built_in&quot;&gt;Tracer&lt;/span&gt;(&lt;span class=&quot;hljs-type&quot;&gt;const&lt;/span&gt; std::string&amp;amp; n) : &lt;span class=&quot;hljs-built_in&quot;&gt;name&lt;/span&gt;(n)
		{
			std::cout &amp;lt;&amp;lt; &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;  [+] &amp;#x27;&amp;quot;&lt;/span&gt; &amp;lt;&amp;lt; name &amp;lt;&amp;lt; &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;&amp;#x27; Tracer created (Constructor)\n&amp;quot;&lt;/span&gt;;
		}

		&lt;span class=&quot;hljs-comment&quot;&gt;// Copy Constructor&lt;/span&gt;
		&lt;span class=&quot;hljs-built_in&quot;&gt;Tracer&lt;/span&gt;(&lt;span class=&quot;hljs-type&quot;&gt;const&lt;/span&gt; Tracer&amp;amp; other) : &lt;span class=&quot;hljs-built_in&quot;&gt;name&lt;/span&gt;(other.name)
		{
			std::cout &amp;lt;&amp;lt; &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;  [*] &amp;#x27;&amp;quot;&lt;/span&gt; &amp;lt;&amp;lt; name &amp;lt;&amp;lt; &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;&amp;#x27; Tracer copy-constructed (Copy Constructor)\n&amp;quot;&lt;/span&gt;;
		}

		~&lt;span class=&quot;hljs-built_in&quot;&gt;Tracer&lt;/span&gt;()
		{
			std::cout &amp;lt;&amp;lt; &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;  [-] &amp;#x27;&amp;quot;&lt;/span&gt; &amp;lt;&amp;lt; name &amp;lt;&amp;lt; &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;&amp;#x27; Tracer destroyed (Destructor)\n&amp;quot;&lt;/span&gt;;
		}
	};

	&lt;span class=&quot;hljs-comment&quot;&gt;// 1. Initialize the variant with a Tracer type.&lt;/span&gt;
	std::cout &amp;lt;&amp;lt; &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;1. Initializing variant with Tracer(\&amp;quot;Apple\&amp;quot;).\n&amp;quot;&lt;/span&gt;;
	std::variant&amp;lt;&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;, Tracer&amp;gt; var = &lt;span class=&quot;hljs-built_in&quot;&gt;Tracer&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;Apple&amp;quot;&lt;/span&gt;);
	std::cout &amp;lt;&amp;lt; &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;   Variant now holds Tracer(\&amp;quot;Apple\&amp;quot;).\n\n&amp;quot;&lt;/span&gt;;

	&lt;span class=&quot;hljs-comment&quot;&gt;// 2. Assign a value of a different type (int).&lt;/span&gt;
	std::cout &amp;lt;&amp;lt; &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;2. Assigning integer 100 to the variant.\n&amp;quot;&lt;/span&gt;;
	var = &lt;span class=&quot;hljs-number&quot;&gt;100&lt;/span&gt;;
	std::cout &amp;lt;&amp;lt; &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;   Variant now holds integer 100.\n\n&amp;quot;&lt;/span&gt;;

	&lt;span class=&quot;hljs-comment&quot;&gt;// 3. Assign another Tracer type value again.&lt;/span&gt;
	std::cout &amp;lt;&amp;lt; &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;3. Assigning Tracer(\&amp;quot;Banana\&amp;quot;) to the variant.\n&amp;quot;&lt;/span&gt;;
	var = &lt;span class=&quot;hljs-built_in&quot;&gt;Tracer&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;Banana&amp;quot;&lt;/span&gt;);
	std::cout &amp;lt;&amp;lt; &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;   Variant now holds Tracer(\&amp;quot;Banana\&amp;quot;).\n\n&amp;quot;&lt;/span&gt;;

	std::cout &amp;lt;&amp;lt; &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;4. main function is about to end.\n&amp;quot;&lt;/span&gt;;
	&lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When you run code like this, you get the following result.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;1. Initializing variant with Tracer(&amp;quot;Apple&amp;quot;).
  [+] &amp;#x27;Apple&amp;#x27; Tracer created (Constructor)
  [*] &amp;#x27;Apple&amp;#x27; Tracer copy-constructed (Copy Constructor)
  [-] &amp;#x27;Apple&amp;#x27; Tracer destroyed (Destructor)
   Variant now holds Tracer(&amp;quot;Apple&amp;quot;).

2. Assigning integer 100 to the variant.
  [-] &amp;#x27;Apple&amp;#x27; Tracer destroyed (Destructor)
   Variant now holds integer 100.

3. Assigning Tracer(&amp;quot;Banana&amp;quot;) to the variant.
  [+] &amp;#x27;Banana&amp;#x27; Tracer created (Constructor)
  [*] &amp;#x27;Banana&amp;#x27; Tracer copy-constructed (Copy Constructor)
  [-] &amp;#x27;Banana&amp;#x27; Tracer destroyed (Destructor)
   Variant now holds Tracer(&amp;quot;Banana&amp;quot;).

4. main function is about to end.
  [-] &amp;#x27;Banana&amp;#x27; Tracer destroyed (Destructor)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can observe the sequence where the destructor for the existing value is called first, followed by the creation of a temporary object on the stack, and finally, the copied value is moved into its own memory buffer.&lt;/p&gt;
&lt;p&gt;Therefore, by internally reserving space for the largest class using a union, the variant type can be used without issues regardless of what is passed in!&lt;/p&gt;
&lt;h4&gt;2. Visit&lt;/h4&gt;
&lt;p&gt;Although this varies by library,&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Function pointer table&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Switch statement&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It is generally categorized into these two main forms. In reality, aside from slight differences in implementation, overhead, and compiler optimization, it can be understood that they are fundamentally implemented to call the appropriate function based on the active type determined by the discriminator.&lt;/p&gt;
</content:encoded></item><item><title>[Jongman Book] 02. Troubleshooting Strategies</title><link>https://www.traceoflight.dev/en/blog/jongmanbook02/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/jongmanbook02/</guid><description>Algorithmic Troubleshooting Strategies Chapter 2 Recap</description><pubDate>Wed, 18 Dec 2024 04:27:16 GMT</pubDate><content:encoded>&lt;h2&gt;Troubleshooting process&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Read and understand the problem.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Redefine the problem in familiar terms.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Plan how to solve the problem.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Validate your plan.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Implement it as a program.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Reflect on how you solved it and look for ways to improve.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;1) Read and understand the problem&lt;/h3&gt;
&lt;p&gt;To avoid making the mistake of misreading the problem, you should read the problem aggressively and try to fully understand what the problem wants. If you miss a small constraint, you will often be unable to solve it, and competitions are often unforgiving of small mistakes.&lt;/p&gt;
&lt;h3&gt;2) Redefinition and abstraction&lt;/h3&gt;
&lt;p&gt;Using concepts that are easy for you to work with, rephrasing the problem in your own language is necessary to intuitively understand what the problem is asking of you, and the more complex the problem, the more important it is.
Programs that do the same thing can be perceived very differently depending on how you reframe the nature of the problem.
Abstraction determines the direction a program will take, as it can make hard problems easier and easy problems harder to solve.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Abstraction: the process of translating real-world concepts into mathematical/computational concepts that are easier for us to deal with.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;3) Plan.&lt;/h3&gt;
&lt;p&gt;Deciding how to solve the problem, choosing the algorithms and data structures to use. This is the most important part of the process, and it&apos;s where you&apos;ll spend the most time if you don&apos;t immediately see a solution to a problem.&lt;/p&gt;
&lt;h3&gt;4) Validate your plan&lt;/h3&gt;
&lt;p&gt;Before starting implementation, we need to validate our plan. We need to prove that the algorithm we designed will correctly perform the requirements in all cases, and that the time it takes to perform and the memory it uses are within the limits of the problem.&lt;/p&gt;
&lt;h3&gt;5) Implementing the plan&lt;/h3&gt;
&lt;p&gt;Always keep efficiency and accuracy in mind when implementing.&lt;/p&gt;
&lt;h3&gt;6) Reflect&lt;/h3&gt;
&lt;p&gt;The step that doesn&apos;t have a direct impact right away, but has the biggest impact in the long run.
When you re-solve a problem you&apos;ve solved before, you may find a more efficient algorithm, write more concise code, or even find a more intuitive way to derive the same algorithm.
The most effective way to do a retrospective is to write down your experience each time you solve a problem.&lt;/p&gt;
&lt;p&gt;Recording your approach, key realizations, and reasons for incorrect answers can help you reduce mistakes and help you pattern. Looking at other people&apos;s code that you&apos;ve solved can also provide insights you might not have thought of.&lt;/p&gt;
&lt;p&gt;Refer to other people&apos;s code or solutions after a period of time, even if you haven&apos;t solved it, but be sure to review it.&lt;/p&gt;
&lt;h2&gt;Troubleshooting strategies&lt;/h2&gt;
&lt;h3&gt;1) Intuition and systematic approach&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Have you solved a similar problem before?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You should be able to understand and transform principles, not just solve them.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Can you start with a simple method?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Can you solve it without knowing it? There is also a way to create the simplest algorithm and implement it through optimization, starting from&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You can establish a baseline for algorithmic efficiency&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Can I formalize the process of solving the problem?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Formalize while solving examples given in the problem, etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Can I simplify the problem?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Solving an easier variant of a given problem first&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Can it be illustrated?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Geometric shapes are more intuitive to accept&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Can it be expressed as a formula?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Plain text → formulas can help solve problems&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Can the problem be decomposed?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;How to transform the problem into a more tractable form, such as decomposing constraints&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Can I solve the problem by thinking from the backwards?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Typical examples: The ladder game.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Can you reduce the number of steps by working your way up from the bottom to the top rather than trying all the paths from the front?&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Can we enforce the order?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;How to enforce order on a problem that doesn&apos;t have it&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Example: Do, don&apos;t, or only 2 cases exist for a single variable / order doesn&apos;t matter → Decide whether or not to transform in order.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Can we only consider certain forms of answers?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Normalization techniques&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;How to group answers that are different in form but the same in result, and consider only the group representatives&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
</content:encoded></item><item><title>[Effective C++] item 02</title><link>https://www.traceoflight.dev/en/blog/effective-cpp-02/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/effective-cpp-02/</guid><description>To write #define, think of const, enum, and inline.</description><pubDate>Tue, 12 Mar 2024 14:40:14 GMT</pubDate><content:encoded>&lt;h3&gt;#Prefer Const, Enum, and Inline over #define&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Expresses preference for compiler over preprocessing&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;#define FOO 1.024&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The above case is a preprocessor that substitutes the string before compilation.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The above symbol FOO can be removed without the compiler being aware of its existence, so it may appear as a constant in errors, so if there is a bug related to this, it will be a waste of time to track it down.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;const double FOO = 1.024;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The solution is to replace the macro with a constant.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The constant is clearly observable by the compiler and is also clearly entered in the symbol table. Also, if the substitution is done in bulk through a preprocessor, multiple copies of the object may be created, but in the case of a constant, no more than one copy is created.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
</content:encoded></item><item><title>[Effective C++] item 01</title><link>https://www.traceoflight.dev/en/blog/effective-cpp-01/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/effective-cpp-01/</guid><description>Viewing C++ as a family of languages is essential</description><pubDate>Tue, 12 Mar 2024 14:01:04 GMT</pubDate><content:encoded>&lt;h3&gt;C++ is a multi-paradigm programming language&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Initially started as C with added object-oriented features&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Currently supports procedural, object-oriented, functional, generic, and even metaprogramming&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Generic programming: A programming paradigm that maximizes reusability by being data type agnostic, meaning that one value can have multiple data types.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Metaprogramming: writing and modifying programs that treat themselves or other programs as data, sometimes referred to as compile-time methods of doing some of the work that needs to be done at runtime.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;C++ should not be viewed as a single language, but as a family of languages, each with their own rules.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;C: Many things originated in C, but C++ often provides a better approach and can be used to a more limited and safe extent.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Object-oriented C++: The core of C++, where classes exist, and where object-oriented design comes into play most directly.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Template C++: Less frequently encountered and rarely interacts with mainstream C++. It has given rise to a powerful paradigm called TMP.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;STL: Template library, but a very special case; there is a specific way to use STL and you must follow its rules.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If there is a transition between the above sublanguages, you may find yourself in a situation where you have to change your strategy.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;C++ will be easier to understand if you understand that it is not a single language, but a collection of sublanguages, each with their own rules.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
</content:encoded></item><item><title>[Effective C++] enters</title><link>https://www.traceoflight.dev/en/blog/effective-cpp-00/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/effective-cpp-00/</guid><description>The Story of Learning Effective C++</description><pubDate>Tue, 12 Mar 2024 12:45:19 GMT</pubDate><content:encoded>&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-fb3d40db998200c1-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;It&apos;s been a while since I&apos;ve posted a study post.&lt;/p&gt;
&lt;p&gt;I haven&apos;t transcribed all of them, but I&apos;m currently working in system development at a company that I thought would be better compared to the company where I wrote about my passing testimonial.&lt;/p&gt;
&lt;p&gt;There was talk of studying this book in the company, so I thought it would be good to utilize the existing platform while studying, and I will continue to write accordingly. I want to do a better job by learning about this book, but I feel a little bitter because it seems to be a long way off...&lt;/p&gt;
&lt;p&gt;I&apos;ll try to keep the posts organized and one for each item. 화이팅!&lt;/p&gt;
</content:encoded></item><item><title>Review of 42Seoul Rapisin</title><link>https://www.traceoflight.dev/en/blog/42seoul-la-piscine/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/42seoul-la-piscine/</guid><description>Review of the 1st Session of the 10th Cohort of Seoul Rapisin</description><pubDate>Sat, 23 Sep 2023 17:19:05 GMT</pubDate><content:encoded>&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;While preparing for my job search, around the middle of this year as SSAFY was nearing its conclusion, I was concerned that my preparation period might be extended. So, while submitting applications to companies, I also took the time to research various bootcamps and training programs.&lt;/p&gt;
&lt;p&gt;As a result, I decided to apply to 42Seoul, as I believed it was the program that best suited me.&lt;/p&gt;
&lt;p&gt;There were several reasons for this, but among them, the emphasis on self-directed learning and time flexibility compared to other bootcamps, as well as the focus on relatively low-level programming languages, were particularly appealing to me.&lt;/p&gt;
&lt;h3&gt;The Rapishin Program&lt;/h3&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-1b1c639d3d343b20-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;After successfully checking in and applying for Rapishin, I received final acceptance offers from several companies while waiting for the Rapishin program to begin. I originally planned to withdraw from the program, but after hearing stories from 42 cadets currently working in the field and considering the 42 curriculum, I judged that it was entirely possible to juggle both. So, I dedicated myself fully to the program in the beginning and then continued it alongside my job.&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-7a35603c5af347f5-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;As those familiar with the 42 program likely know, there is a pre-course called &amp;quot;Rapicin&amp;quot; that must be completed before admission and the main program. This course is quite grueling...&lt;/p&gt;
&lt;p&gt;If you’re a non-major with no prior background, keeping up might be a struggle, but if you’re a non-major with some programming knowledge, I believe you can achieve the desired results if you work hard. As for majors, I believe admission to the main program wouldn’t have been difficult unless they were unable to focus on the course for other reasons or were unfairly treated.&lt;/p&gt;
&lt;p&gt;This is just my personal opinion, but since the education provided at 42 is quite similar to a university curriculum, I think it might actually be better suited for non-majors. For majors who have already completed a solid education in the field at university, the benefits offered by 42—excluding the financial aid and other support systems—seemed relatively lacking compared to other bootcamps.&lt;/p&gt;
&lt;p&gt;The reason I considered joining the program, aside from the financial aid, was that I believed it offered a solid curriculum to fill the gaps in my lack of specialized knowledge. Since that fundamental premise didn’t change even after I secured a job, I was able to complete the Rapishin program.&lt;/p&gt;
&lt;p&gt;(Naturally, you can’t receive financial aid after getting a job...)&lt;/p&gt;
&lt;h3&gt;Results&lt;/h3&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-881466acbebffd64-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Fortunately, I achieved a good result and was accepted into the 10th cohort of 42Seoul. Since the program uses a tech stack similar to my current role at work, I’m looking forward to creating a positive feedback loop that benefits both areas.&lt;/p&gt;
&lt;h3&gt;Q &amp;amp; A&lt;/h3&gt;
&lt;p&gt;Let me answer some common questions about the program:&lt;/p&gt;
&lt;h4&gt;1. Can a non-computer science major with no prior experience get accepted?&lt;/h4&gt;
&lt;blockquote&gt;&lt;/blockquote&gt;
&lt;p&gt;While it might have been possible in the early cohorts, re-applications are now allowed, and with so much information available today, it’s nearly impossible.&lt;/p&gt;
&lt;h4&gt;2. Who would you recommend this program to?&lt;/h4&gt;
&lt;blockquote&gt;&lt;/blockquote&gt;
&lt;p&gt;Undergraduate students who still have plenty of time left in their degree programs, and non-majors who aren’t focused on immediate employment but want to build a solid foundation over a longer period.&lt;/p&gt;
&lt;h4&gt;3. What should you know before joining?&lt;/h4&gt;
&lt;blockquote&gt;&lt;/blockquote&gt;
&lt;p&gt;The more you know—such as basic C concepts and pointers (which can be hard to grasp at first)—the better. Everyone emphasizes learning how to use the Shell, but I’d also add the advice to familiarize yourself with Git.&lt;/p&gt;
&lt;h4&gt;4. What would you definitely recommend trying during the program?&lt;/h4&gt;
&lt;blockquote&gt;&lt;/blockquote&gt;
&lt;p&gt;Personally, the members of my first Rush team were wonderful people, and having completed the program with them, I’d say that while interacting with others isn’t strictly necessary, if the opportunity arises, don’t miss out on connecting with them. For developers, communication skills are just as important as coding!&lt;/p&gt;
</content:encoded></item><item><title>[Glossary] File System</title><link>https://www.traceoflight.dev/en/blog/file-system/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/file-system/</guid><description>Glossary of terms used in file system-related work</description><pubDate>Thu, 14 Sep 2023 14:36:39 GMT</pubDate><content:encoded>&lt;h3&gt;in&lt;/h3&gt;
&lt;p&gt;I realized that my knowledge of the underlying terminology was a bit lacking in my current role, so I decided to take the time to do some additional research and briefly summarize the terms I did know.&lt;/p&gt;
&lt;h3&gt;File Descriptor&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;in Linux, Unix-like systems&lt;/li&gt;
&lt;li&gt;a type of value used by a Process when dealing with a File.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;When a process opens a file, the kernel assigns it the smallest, unused value of the processor&apos;s file descriptor number, so that the next time the open file is accessed with a system call, the descriptor value can be used to refer to the file.&lt;/p&gt;
&lt;blockquote&gt;
&lt;h4&gt;Default Assigned Descriptors&lt;/h4&gt;
&lt;/blockquote&gt;
&lt;ol&gt;
&lt;li&gt;standard input (Standard Input)&lt;/li&gt;
&lt;li&gt;standard output&lt;/li&gt;
&lt;li&gt;Standard Error&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Inode&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Short for Index Node, a node for quickly locating files.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;An inode is a node that indexes all files in Linux and holds metadata about those files. The inode holds the metadata that is output by the list command.&lt;/p&gt;
&lt;h3&gt;Symbolic Link&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;A file with information pointing to the inode of the source file.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Internally, files are accessed via inode number&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;has a new inode that does not hold information about the original file&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;cf) Hard Link&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A file with a new inode, not a file with a new inode, just the inode copied verbatim&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The difference from a true copy is that no additional data is written, unlike copying&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Block Device &amp;amp; Character Device&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Classifies devices by the difference in data transfer method&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Block: Transfers data in quantitative units such as blocks or sectors, faster IO transfer speeds&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Character: Transfers data in bytes, IO transfer speed may be slightly slower, but performance differences exist through buffering control at the application end.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Raw Device&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Device without file system set up&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Not buffered by the OS kernel, data is transferred directly from the device, and it has its own caching system.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Good disk IO performance, low CPU overhead.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Avoids OS file system overhead and can reduce OS buffer size.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Used as a raw device because concurrent access is not possible when configured in the system for shared disks.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;IO Scheduler&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;The part of the system that sorts, merges, and determines the order in which requests are processed to make disk I/O efficient.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Particularly useful for devices such as HDDs, where seek times are expensive and merging requests for the same location is effective; effectiveness is halved on SSDs.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Types.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;noop: no-operation, used for high-performance disks&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;cfq (completely fair queueing): Give each process an IO queue and schedule them as evenly as possible, used when a large number of processes generate fine-grained IO&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;deadline: prioritizes closer to the threshold, optimizes for latency, balances all I/O, and is ideal for environments where a small number of processes generate a large amount of I/O.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;anticipacy: Predicts the location of future I/O requests and processes the closest I/O requests first; the structure used by traditional HDDs, which aggregate input and output, may increase latency.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
</content:encoded></item><item><title>[BOJ 9519, CPP] sleepy</title><link>https://www.traceoflight.dev/en/blog/boj9519/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/boj9519/</guid><description>BOJ 9519, C++ Solution to the &quot;Sleepy&quot; Problem</description><pubDate>Mon, 04 Sep 2023 14:32:38 GMT</pubDate><content:encoded>&lt;h3&gt;Problem link&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;@@tlp3@@&quot;&gt;boj 9519&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Classification&lt;/h3&gt;
&lt;p&gt;Implementations, Strings, Simulation&lt;/p&gt;
&lt;h3&gt;Description&lt;/h3&gt;
&lt;p&gt;This problem was initially solved by full exploration.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Measure the length of the string first&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;0 ~ assign a vector of numbers equal to the length of the string&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Repeat and flip based on problem conditions&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Once flipped a number of times, utilize the corresponding hash value to place them in reverse order&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You can see the original look!&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The most important thing to note here is that you can flip it over and over again, depending on the conditions of the problem, and the cycle will always come back the same as the initial array.&lt;/p&gt;
&lt;p&gt;Once you&apos;ve found the rule above and refined it, you can use the&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Measure the length of the string first&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;0 ~ assign a vector of numbers equal to the length of the string&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;check for a cycle from 1 to (length of string - 1) times&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;iterate over the total number of flips divided by the number of cycles to derive the hash&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If flipped a certain number of times, utilize that hash value to reverse the order&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You can see the original image!&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It will look like this&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;    &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; i = &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;; i &amp;lt;= target_length - &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;; i++)
    {
        &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; j = &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; j &amp;lt; target_length / &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;; j++)
        {
            temp = result.&lt;span class=&quot;hljs-built_in&quot;&gt;back&lt;/span&gt;();
            result.&lt;span class=&quot;hljs-built_in&quot;&gt;pop_back&lt;/span&gt;();
            result.&lt;span class=&quot;hljs-built_in&quot;&gt;insert&lt;/span&gt;(result.&lt;span class=&quot;hljs-built_in&quot;&gt;begin&lt;/span&gt;() + &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt; * j + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, temp);
        }

		&lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (start_vector == result)
		{
			cycle = i;
			&lt;span class=&quot;hljs-keyword&quot;&gt;break&lt;/span&gt; ;
		}
    }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Initially, we moved the array directly as shown above, but this caused some overhead because we had to move the entire array after the insert, so it took a little longer.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;    &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; i = &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;; i &amp;lt;= target_length - &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;; i++)
    {
		temp_vector.&lt;span class=&quot;hljs-built_in&quot;&gt;clear&lt;/span&gt;();
		temp_vector.&lt;span class=&quot;hljs-built_in&quot;&gt;resize&lt;/span&gt;(target_length);
        &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; j = &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; j &amp;lt; target_length; j++)
        {
			&lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (!(j % &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;))
				temp_vector[j] = result[j / &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;];
			&lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;
				temp_vector[j] = result[target_length - &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt; - (j / &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;)];
        }

		&lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (start_vector == temp_vector)
		{
			cycle = i;
			&lt;span class=&quot;hljs-keyword&quot;&gt;break&lt;/span&gt; ;
		}
		&lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;
			result = temp_vector;
    }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Therefore, we used the above method to create the array in advance and insert the values one by one, so that the time is only used for the maximum length of the array.&lt;/p&gt;
&lt;h3&gt;Solving code&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;// 졸려&lt;/span&gt;

&lt;span class=&quot;hljs-meta&quot;&gt;#&lt;span class=&quot;hljs-keyword&quot;&gt;include&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;hljs-meta&quot;&gt;#&lt;span class=&quot;hljs-keyword&quot;&gt;include&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;&amp;lt;vector&amp;gt;&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;hljs-keyword&quot;&gt;using&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;namespace&lt;/span&gt; std;

&lt;span class=&quot;hljs-function&quot;&gt;vector&amp;lt;&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;&amp;gt; &lt;span class=&quot;hljs-title&quot;&gt;flicker_action&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; target_length, &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; count)&lt;/span&gt;&lt;/span&gt;;

&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(&lt;span class=&quot;hljs-type&quot;&gt;void&lt;/span&gt;)&lt;/span&gt;
&lt;/span&gt;{
    ios_base::&lt;span class=&quot;hljs-built_in&quot;&gt;sync_with_stdio&lt;/span&gt;(&lt;span class=&quot;hljs-literal&quot;&gt;false&lt;/span&gt;);
    cin.&lt;span class=&quot;hljs-built_in&quot;&gt;tie&lt;/span&gt;(&lt;span class=&quot;hljs-literal&quot;&gt;NULL&lt;/span&gt;);
    cout.&lt;span class=&quot;hljs-built_in&quot;&gt;tie&lt;/span&gt;(&lt;span class=&quot;hljs-literal&quot;&gt;NULL&lt;/span&gt;);

    &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; flicker_number;
    string result_string, init_string;
    vector&amp;lt;&lt;span class=&quot;hljs-type&quot;&gt;char&lt;/span&gt;&amp;gt; string_vector;
    vector&amp;lt;&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;&amp;gt; idx_vector;

    cin &amp;gt;&amp;gt; flicker_number;
    cin.&lt;span class=&quot;hljs-built_in&quot;&gt;ignore&lt;/span&gt;();
    &lt;span class=&quot;hljs-built_in&quot;&gt;getline&lt;/span&gt;(cin, result_string);

    &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; i = &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; i &amp;lt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;) result_string.&lt;span class=&quot;hljs-built_in&quot;&gt;length&lt;/span&gt;(); i++)
        string_vector.&lt;span class=&quot;hljs-built_in&quot;&gt;push_back&lt;/span&gt;(result_string[i]);
    

    idx_vector = &lt;span class=&quot;hljs-built_in&quot;&gt;flicker_action&lt;/span&gt;(result_string.&lt;span class=&quot;hljs-built_in&quot;&gt;length&lt;/span&gt;(), flicker_number);
    init_string.&lt;span class=&quot;hljs-built_in&quot;&gt;resize&lt;/span&gt;(result_string.&lt;span class=&quot;hljs-built_in&quot;&gt;length&lt;/span&gt;());

    &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; i = &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; i &amp;lt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;) result_string.&lt;span class=&quot;hljs-built_in&quot;&gt;length&lt;/span&gt;(); i++)
        init_string[idx_vector[i]] = result_string[i];

    cout &amp;lt;&amp;lt; init_string &amp;lt;&amp;lt; endl;
    &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; (&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;);
}

&lt;span class=&quot;hljs-function&quot;&gt;vector&amp;lt;&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;&amp;gt; &lt;span class=&quot;hljs-title&quot;&gt;flicker_action&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; target_length, &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; count)&lt;/span&gt;
&lt;/span&gt;{
    vector&amp;lt;&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;&amp;gt; result, temp_vector, start_vector;
	&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; cycle;

    &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; i = &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; i &amp;lt; target_length; i++)
        result.&lt;span class=&quot;hljs-built_in&quot;&gt;push_back&lt;/span&gt;(i);

	start_vector = result;
	cycle = &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;;

    &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; i = &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;; i &amp;lt;= target_length - &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;; i++)
    {
		temp_vector.&lt;span class=&quot;hljs-built_in&quot;&gt;clear&lt;/span&gt;();
		temp_vector.&lt;span class=&quot;hljs-built_in&quot;&gt;resize&lt;/span&gt;(target_length);
        &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; j = &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; j &amp;lt; target_length; j++)
        {
			&lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (!(j % &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;))
				temp_vector[j] = result[j / &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;];
			&lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;
				temp_vector[j] = result[target_length - &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt; - (j / &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;)];
        }

		&lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (start_vector == temp_vector)
		{
			cycle = i;
			&lt;span class=&quot;hljs-keyword&quot;&gt;break&lt;/span&gt; ;
		}
		&lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;
			result = temp_vector;
    }

	result = start_vector;

    &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; i = &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; i &amp;lt; (count % cycle); i++)
    {
		temp_vector.&lt;span class=&quot;hljs-built_in&quot;&gt;clear&lt;/span&gt;();
		temp_vector.&lt;span class=&quot;hljs-built_in&quot;&gt;resize&lt;/span&gt;(target_length);
        &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; j = &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; j &amp;lt; target_length; j++)
        {
			&lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (!(j % &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;))
				temp_vector[j] = result[j / &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;];
			&lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;
				temp_vector[j] = result[target_length - &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt; - (j / &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;)];
        }

		result = temp_vector;
    }

    &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; (result);
}
&lt;/code&gt;&lt;/pre&gt;
</content:encoded></item><item><title>[BOJ 4821, CPP] Page counting</title><link>https://www.traceoflight.dev/en/blog/boj4821/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/boj4821/</guid><description>C++ Solution to BOJ 4821, &quot;Page Counting&quot; Problem</description><pubDate>Sat, 26 Aug 2023 15:04:16 GMT</pubDate><content:encoded>&lt;h3&gt;Problem link&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;@@tlp1@@&quot;&gt;boj 4821&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Classification&lt;/h3&gt;
&lt;p&gt;Implementations, Strings, Parsing&lt;/p&gt;
&lt;h3&gt;Include&lt;/h3&gt;
&lt;p&gt;I recently joined a new company, and it&apos;s been quite a busy time. I&apos;m a new employee who feels a lot of pressure just being in the company... However, I&apos;ve been writing down various stories, so I&apos;m sure I&apos;ll be able to tell them sooner or later.&lt;/p&gt;
&lt;p&gt;Recently, I had a great opportunity to learn C, and I&apos;m always disappointed when I hit a time wall with Python or Java, so I wanted to take this opportunity to solve problems in C++.&lt;/p&gt;
&lt;p&gt;From my short experience with it, I have a pretty good feeling that the implementation is quite cumbersome, but the speed compensates for it. If I can master it, will I be able to take advantage of the speed...? I&apos;m looking forward to it.&lt;/p&gt;
&lt;h3&gt;Description.&lt;/h3&gt;
&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Vector: dynamic array structure, similar to an array, but with the big advantage that the size can be flexibly changed and memory allocation is automatic!&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;npos: no position, an index value to check when the position is invalid.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;stringstream: a device for treating strings as streams, allowing them to be treated in the same way as input and output, often used for parsing&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;p&gt;The basic logic is to create a bool array to cover the entire range of pages, then check for all the pages that came in and print the count at the end.&lt;/p&gt;
&lt;p&gt;However, it&apos;s worth noting that the range of numbers given in the problem can be given as values beyond int, so you&apos;ll need to set a variable to control that, and there are exceptions to not check if the range is given in reverse order.&lt;/p&gt;
&lt;p&gt;This was fairly easy to do in Python, but in C++, the code became very long...&lt;/p&gt;
&lt;h3&gt;Solution code&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;// 페이지 세기&lt;/span&gt;

&lt;span class=&quot;hljs-meta&quot;&gt;#&lt;span class=&quot;hljs-keyword&quot;&gt;include&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;hljs-meta&quot;&gt;#&lt;span class=&quot;hljs-keyword&quot;&gt;include&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;&amp;lt;vector&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;hljs-meta&quot;&gt;#&lt;span class=&quot;hljs-keyword&quot;&gt;include&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;&amp;lt;sstream&amp;gt;&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;hljs-keyword&quot;&gt;using&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;namespace&lt;/span&gt; std;

&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(&lt;span class=&quot;hljs-type&quot;&gt;void&lt;/span&gt;)&lt;/span&gt;
&lt;/span&gt;{
	ios_base::&lt;span class=&quot;hljs-built_in&quot;&gt;sync_with_stdio&lt;/span&gt;(&lt;span class=&quot;hljs-literal&quot;&gt;false&lt;/span&gt;);
	cin.&lt;span class=&quot;hljs-built_in&quot;&gt;tie&lt;/span&gt;(&lt;span class=&quot;hljs-literal&quot;&gt;NULL&lt;/span&gt;);
	cout.&lt;span class=&quot;hljs-built_in&quot;&gt;tie&lt;/span&gt;(&lt;span class=&quot;hljs-literal&quot;&gt;NULL&lt;/span&gt;);

	&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;				total_page, seperator, start, end, result;
	string			temp, each_range;
	vector&amp;lt;string&amp;gt;	line_info;
	vector&amp;lt;&lt;span class=&quot;hljs-type&quot;&gt;bool&lt;/span&gt;&amp;gt;	print_info;
	vector&amp;lt;&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;&amp;gt;		result_vector;

	&lt;span class=&quot;hljs-keyword&quot;&gt;while&lt;/span&gt; (&lt;span class=&quot;hljs-literal&quot;&gt;true&lt;/span&gt;)
	{
		cin &amp;gt;&amp;gt; total_page;

		&lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (!total_page)
			&lt;span class=&quot;hljs-keyword&quot;&gt;break&lt;/span&gt; ;
		&lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;
		{
			print_info.&lt;span class=&quot;hljs-built_in&quot;&gt;assign&lt;/span&gt;(&lt;span class=&quot;hljs-number&quot;&gt;1001&lt;/span&gt;, &lt;span class=&quot;hljs-literal&quot;&gt;false&lt;/span&gt;);
			cin.&lt;span class=&quot;hljs-built_in&quot;&gt;ignore&lt;/span&gt;();
			&lt;span class=&quot;hljs-built_in&quot;&gt;getline&lt;/span&gt;(cin, temp);
			&lt;span class=&quot;hljs-function&quot;&gt;stringstream &lt;span class=&quot;hljs-title&quot;&gt;range_stream&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(temp)&lt;/span&gt;&lt;/span&gt;;

			&lt;span class=&quot;hljs-keyword&quot;&gt;while&lt;/span&gt; (&lt;span class=&quot;hljs-built_in&quot;&gt;getline&lt;/span&gt;(range_stream, each_range, &lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;,&amp;#x27;&lt;/span&gt;))
			{
				&lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (each_range.&lt;span class=&quot;hljs-built_in&quot;&gt;find&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;-&amp;#x27;&lt;/span&gt;) == string::npos)
				{
					&lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (each_range.&lt;span class=&quot;hljs-built_in&quot;&gt;length&lt;/span&gt;() &amp;lt; &lt;span class=&quot;hljs-number&quot;&gt;5&lt;/span&gt; &amp;amp;&amp;amp; &lt;span class=&quot;hljs-built_in&quot;&gt;stoi&lt;/span&gt;(each_range) &amp;lt;= &lt;span class=&quot;hljs-number&quot;&gt;1000&lt;/span&gt;)
						print_info[&lt;span class=&quot;hljs-built_in&quot;&gt;stoi&lt;/span&gt;(each_range)] = &lt;span class=&quot;hljs-literal&quot;&gt;true&lt;/span&gt;;
				}
				&lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;
				{
					seperator = each_range.&lt;span class=&quot;hljs-built_in&quot;&gt;find&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;-&amp;#x27;&lt;/span&gt;);
					&lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (each_range.&lt;span class=&quot;hljs-built_in&quot;&gt;substr&lt;/span&gt;(&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, seperator).&lt;span class=&quot;hljs-built_in&quot;&gt;length&lt;/span&gt;() &amp;lt; &lt;span class=&quot;hljs-number&quot;&gt;5&lt;/span&gt;
						&amp;amp;&amp;amp; &lt;span class=&quot;hljs-built_in&quot;&gt;stoi&lt;/span&gt;(each_range.&lt;span class=&quot;hljs-built_in&quot;&gt;substr&lt;/span&gt;(&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, seperator)) &amp;lt;= &lt;span class=&quot;hljs-number&quot;&gt;1000&lt;/span&gt;)
						start = &lt;span class=&quot;hljs-built_in&quot;&gt;stoi&lt;/span&gt;(each_range.&lt;span class=&quot;hljs-built_in&quot;&gt;substr&lt;/span&gt;(&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, seperator));
					&lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;
						start = &lt;span class=&quot;hljs-number&quot;&gt;1001&lt;/span&gt;;
					&lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (each_range.&lt;span class=&quot;hljs-built_in&quot;&gt;substr&lt;/span&gt;(seperator + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, each_range.&lt;span class=&quot;hljs-built_in&quot;&gt;size&lt;/span&gt;()).&lt;span class=&quot;hljs-built_in&quot;&gt;length&lt;/span&gt;() &amp;lt; &lt;span class=&quot;hljs-number&quot;&gt;5&lt;/span&gt; 
						&amp;amp;&amp;amp; &lt;span class=&quot;hljs-built_in&quot;&gt;stoi&lt;/span&gt;(each_range.&lt;span class=&quot;hljs-built_in&quot;&gt;substr&lt;/span&gt;(seperator + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, each_range.&lt;span class=&quot;hljs-built_in&quot;&gt;size&lt;/span&gt;())) &amp;lt;= &lt;span class=&quot;hljs-number&quot;&gt;1000&lt;/span&gt;)
						end = &lt;span class=&quot;hljs-built_in&quot;&gt;stoi&lt;/span&gt;(each_range.&lt;span class=&quot;hljs-built_in&quot;&gt;substr&lt;/span&gt;(seperator + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, each_range.&lt;span class=&quot;hljs-built_in&quot;&gt;size&lt;/span&gt;()));
					&lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;
						end = &lt;span class=&quot;hljs-number&quot;&gt;1001&lt;/span&gt;;
					&lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (start &amp;lt;= end)
					{
						&lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; i = start; i &amp;lt;= end; i++)
						{
							&lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (i &amp;lt;= total_page)
								print_info[i] = &lt;span class=&quot;hljs-literal&quot;&gt;true&lt;/span&gt;;
						}
					}
				}
			}

			result = &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;;
			&lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; i = &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;; i &amp;lt;= total_page; i++)
			{
				&lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (print_info[i])
					result++;
			}
			result_vector.&lt;span class=&quot;hljs-built_in&quot;&gt;push_back&lt;/span&gt;(result);
		}
	}

	&lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; i = &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; i &amp;lt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;) result_vector.&lt;span class=&quot;hljs-built_in&quot;&gt;size&lt;/span&gt;(); i++)
		cout &amp;lt;&amp;lt; result_vector[i] &amp;lt;&amp;lt; endl;

	&lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; (&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;);
}

&lt;/code&gt;&lt;/pre&gt;
</content:encoded></item><item><title>Miscellaneous Shell Notes (3)</title><link>https://www.traceoflight.dev/en/blog/shell-3/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/shell-3/</guid><description>The Journey of Learning Shell, Part 3</description><pubDate>Tue, 25 Jul 2023 18:05:52 GMT</pubDate><content:encoded>&lt;blockquote&gt;&lt;/blockquote&gt;
&lt;p&gt;07/26/23 Corrected typos&lt;/p&gt;
&lt;blockquote&gt;&lt;/blockquote&gt;
&lt;p&gt;07/27/23 Added command&lt;/p&gt;
&lt;h3&gt;BC&lt;/h3&gt;
&lt;p&gt;Short for Basic Calculator, this is a calculator provided in accordance with the POSIX standard and available on Unix-based systems.&lt;/p&gt;
&lt;p&gt;Key features include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Stack-based structure&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Support for Reverse Polish notation (RPN)&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;hljs-built_in&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;2 + 3&amp;#x27;&lt;/span&gt; | dc
dc &amp;lt;&amp;lt;&amp;lt; &lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;2 3 + p&amp;#x27;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;TR&lt;/h3&gt;
&lt;p&gt;A command that enables character conversion, deletion, and compression. It is typically used in conjunction with additional processes via a pipeline.&lt;/p&gt;
&lt;p&gt;*&lt;code&gt;tr [문자열1] [문자열2]&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;: Takes two strings of equal length and replaces the corresponding characters in string 1 with the characters at the same indices in string 2.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;-c: Replaces all characters not present in the second set with the last character of that set.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;-s: Removes all repeating sequences and replaces them with a specified character.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;-d: Removes the specified character.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;-t: Trims both strings to match their lengths before executing the command.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;SED (&lt;/h3&gt;
&lt;blockquote&gt;&lt;/blockquote&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;p&gt;A command that supports various editing functions. It operates primarily on a buffer, so the original file remains unaffected until modifications are applied.&lt;/p&gt;
&lt;h4&gt;Command Options&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Patterns are expressed in the form /[pattern]/.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add -g to process all matching patterns.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Use commas (,) to specify ranges.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;p: Prints all lines and prints an additional line for each pattern match&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Add the -n option: Excludes default output; prints only lines matching the pattern&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;d: Deletes the pattern&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;s: Replaces the pattern&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;e: Edit mode&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;*&lt;code&gt;n;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;: Next line&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;y: Y-confirmation&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;i: Insert&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;c: Change&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;a: Append&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;# 약간의 응용&lt;/span&gt;

sed -n &lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;n; p&amp;#x27;&lt;/span&gt;: 짝수 줄 출력
sed -n &lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;p; n&amp;#x27;&lt;/span&gt;: 홀수 줄 출력
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;WC&lt;/h3&gt;
&lt;blockquote&gt;&lt;/blockquote&gt;
&lt;p&gt;Word Count&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;-l: Check the number of lines in the file&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;-c: Check the number of bytes in the file&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;-m: Check the number of characters in the file&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;-w: Check the number of words in the file&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
</content:encoded></item><item><title>Miscellaneous Shell History (2)</title><link>https://www.traceoflight.dev/en/blog/shell-2/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/shell-2/</guid><description>A journey to learn Shell, part 2</description><pubDate>Thu, 20 Jul 2023 16:49:40 GMT</pubDate><content:encoded>&lt;h3&gt;List&lt;/h3&gt;
&lt;p&gt;Commands usually used with &lt;code&gt;ls&lt;/code&gt;. You can use these commands to see the contents of a directory. The additional commands are useful because they allow you to pull out the list for appropriate purposes.&lt;/p&gt;
&lt;p&gt;We&apos;ll leave the commands we use most often and the commands we need for specific applications, and if you need more, you can use &lt;code&gt;man&lt;/code&gt; to get the manual or refer to the documentation linked below.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;-l&lt;/strong&gt;: Long Default Format.
&lt;code&gt;working john 2008-07-25 11:56 csrc 1 alias.c-4.5 27&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;-al&lt;/strong&gt;: displays the full text.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;-t&lt;/strong&gt;: Sort by modified time.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;-m&lt;/strong&gt;: output each element separated by commas and spaces (, )
&lt;code&gt;this, is, example&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;-r&lt;/strong&gt;: output in the reverse of the current order&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;-R&lt;/strong&gt;: recursively prints the contents of subdirectories&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;-h&lt;/strong&gt;: Print units in human-readable format (using units like m, k, g, etc.)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;a href=&quot;https://man7.org/linux/man-pages/man1/ls.1.html&quot;&gt;List Manual&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Find&lt;/h3&gt;
&lt;p&gt;This command searches for a file, searching through all subdirectories based on a given location and printing the results. It provides a lot more functionality than just output, and if you really want to get the most out of it, you&apos;ll need to learn about regular expressions.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;-name&lt;/strong&gt;: This is a command to add information about the name of the search, which can be restricted through regular expressions.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;-o&lt;/strong&gt;: This command works like the or operator, if you want to have an action a if condition A and an action b if condition B, use this command.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;-exec&lt;/strong&gt;: a command that allows you to apply additional commands.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;-delete&lt;/strong&gt;: command to remove the found file&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;-print&lt;/strong&gt;: command to print the found files&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Similarly, you can search for other commands here.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://man7.org/linux/man-pages/man1/find.1.html&quot;&gt;Find Manual&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Echo &amp;amp; Printf&lt;/h3&gt;
&lt;p&gt;I use echo a lot in the shell, but besides echo, you can also use printf. Honestly, I don&apos;t know much about it except whether it defaults to newline or not, so I asked ChatGPT to help me with this part!&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-2f0cb8656eb567ac-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Surprisingly, printf is a bit more sophisticated than echo, which I often use. I don&apos;t think I&apos;ll notice any difference in light use, so I&apos;ll go with this information for now...&lt;/p&gt;
</content:encoded></item><item><title>Miscellaneous Shell History (1)</title><link>https://www.traceoflight.dev/en/blog/shell-1/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/shell-1/</guid><description>Your journey to learn Shell</description><pubDate>Mon, 17 Jul 2023 17:25:08 GMT</pubDate><content:encoded>&lt;h3&gt;File creation related&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;touch&lt;/code&gt;: Create file&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;mkdir&lt;/code&gt;: Create folder&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;chmod&lt;/code&gt;: Set file permissions&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;chown&lt;/code&gt;: Set file owner&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;mv&lt;/code&gt;: Move and rename files&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Check file information&lt;/h3&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-f343d0b04676158d-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;-rwxr-xr-x&lt;/code&gt; Part: Checking the file&apos;s permissions&lt;/li&gt;
&lt;/ul&gt;
&lt;ol&gt;
&lt;li&gt;the first digit means File Type (-, d, l)&lt;/li&gt;
&lt;li&gt;read-write-execute permissions are expressed in 3-digit form for user, group, and others,
The value of &lt;code&gt;rwx&lt;/code&gt; can be changed to 7 and &lt;code&gt;-xr&lt;/code&gt; can be changed to 4 because r has a value of 4, w has a value of 2, and x has a value of 1 in the form of a binary number.&lt;/li&gt;
&lt;/ol&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;hljs-built_in&quot;&gt;chmod&lt;/span&gt; 744 Slack.lnk
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This type of command can be used to set permissions.
3. Number of links (where 1 is written)
4. Information about the owner (blank) and ownership group (197609)
5. File size
6. Information about the last modified time
7. The file name&lt;/p&gt;
&lt;h3&gt;ssh-keygen&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Used in many cases for Git authentication via Secure Shell public key&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Included in Window and Linux packages&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;When generating a key, a key and &lt;code&gt;.pub&lt;/code&gt; file is generated, which is used as a key-lock by providing the contents of the .pub file to the server&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;How to adjust the capacity of a file in the shell&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;mkfile -n 10k test.sh
fallocate -l 10k test.sh
&lt;span class=&quot;hljs-built_in&quot;&gt;truncate&lt;/span&gt; -s 10k test.sh
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can resize an existing file or create a new file with this command.&lt;/p&gt;
&lt;h3&gt;Change the file modification history&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;hljs-built_in&quot;&gt;touch&lt;/span&gt; -t 2301011234 timefile.sh
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Command to change the modification history of a file to show that it was last modified on 1/1/23/12:34 as an application of touch.&lt;/p&gt;
&lt;h3&gt;Hard Link &amp;amp; Symbolic Link&lt;/h3&gt;
&lt;h4&gt;Symbolic Link (Soft Link)&lt;/h4&gt;
&lt;p&gt;A link that makes the original file available in a specific folder, such as a shortcut in Windows, and does not work if the original is deleted.&lt;/p&gt;
&lt;h4&gt;Hard Link&lt;/h4&gt;
&lt;p&gt;Unlike a symbolic link, the difference is that it copies the original and creates a copy; when the original is deleted, the symbolic link becomes unusable, but a hard link can still be used because it is the same file after all; links that are involved in the number of links.&lt;/p&gt;
&lt;h4&gt;Code&lt;/h4&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;hljs-built_in&quot;&gt;ln&lt;/span&gt; [대상 폴더] [만들 링크 파일명] &lt;span class=&quot;hljs-comment&quot;&gt;# Hard Link&lt;/span&gt;
&lt;span class=&quot;hljs-built_in&quot;&gt;ln&lt;/span&gt; -s [대상 폴더] [만들 링크 파일명] &lt;span class=&quot;hljs-comment&quot;&gt;# Symbolic Link&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The erase command can be lifted with &lt;code&gt;rm&lt;/code&gt;, just like erasing a file&lt;/p&gt;
&lt;h3&gt;Diff &amp;amp; Patch&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;diff a b &amp;gt; difference.patch
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;diff&lt;/code&gt; command compares two files on a line-by-line basis, and the &lt;code&gt;patch&lt;/code&gt; command allows you to modify a file based on the comparison made by diff.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;patch -p{패치 경로의 depth} [원본] [patch 파일] &lt;span class=&quot;hljs-comment&quot;&gt;# 패치 파일 적용&lt;/span&gt;
patch -p{패치 경로의 depth} -R [원본] [patch 파일] &lt;span class=&quot;hljs-comment&quot;&gt;# 적용된 패치 파일을 되돌림&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the same form as above, you can apply and remove the contents determined through diff from an existing file.&lt;/p&gt;
</content:encoded></item><item><title>2023 Asiana IDT Summer Recruitment Review</title><link>https://www.traceoflight.dev/en/blog/2023-idt/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/2023-idt/</guid><description>How I got involved in Asiana IDT&apos;s recruitment process</description><pubDate>Sat, 15 Jul 2023 09:23:14 GMT</pubDate><content:encoded>&lt;h3&gt;in&lt;/h3&gt;
&lt;p&gt;Development jobs are also affected by the economy, so the number of screenings and hiring is much lower than last year. In the end, the winner is the one who can get the job when the time comes, so I think I need to be more consistent.&lt;/p&gt;
&lt;h3&gt;Document screening &amp;amp; competency testing&lt;/h3&gt;
&lt;p&gt;As with other companies, there was nothing unusual about the documents, but the competency test, which is similar to financial recruitment, was unusual.&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-de67b160b1aa0129-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I thought I answered everything normally, but I was worried because (Caution) appeared, but there was no problem with the cam or microphone, so I submitted it as it was,&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-bfb139a0580b844d-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I was able to pass without any problems. If I had more time, I would have checked the competency check one more time.&lt;/p&gt;
&lt;h3&gt;Coding test&lt;/h3&gt;
&lt;p&gt;The difficulty level and question types reminded me of coding tests in finance. Overall, the difficulty level was average, and SQL was similar.&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-04f741f5ffa434c7-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I passed and got a chance to interview at Asiana IDT!&lt;/p&gt;
&lt;h3&gt;Final Interview&lt;/h3&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-3d3262bf0a5592a0-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I picked up my interviewer&apos;s visitor&apos;s pass at the entrance of the building and went to the interview, which was similar to the other reviews I had read in preparation.&lt;/p&gt;
&lt;p&gt;I wasn&apos;t expecting to play a big role in the discussion interview, but I thought it was a process to screen out people with communication problems.&lt;/p&gt;
&lt;p&gt;In the personality interview, I was asked questions based on a combination of documents, coding test results, etc.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;I don&apos;t think there are many people like this when applying for a job, but I thought that people who haven&apos;t researched the company enough might have difficulty with the questions.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;I realized that the company was thinking about the direction of the company&apos;s development by asking interviewees for their opinions.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;End result.&lt;/h3&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-1e2142ef3cf56fc9-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I thought I answered better than usual in the interview, but I managed to get the job despite the high competition!&lt;/p&gt;
&lt;h3&gt;Impressions&lt;/h3&gt;
&lt;p&gt;When entering the IT industry, many people have a vague fear of SI/SM because of all the stories they hear, and that&apos;s exactly what I did.&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-94c515233c0d9259-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;
~~Hyper Realism&lt;/p&gt;
&lt;p&gt;However, I think that most of the domestic IT industry is centered on SI/SM, not IT services, and if you overlook this, you may make irrational choices.&lt;/p&gt;
&lt;p&gt;As the job market is not the same as it used to be, I think it is time to have the sense to consider what is the best option you can do now rather than going for too narrow a goal, and if you keep this in mind, you will get good results!&lt;/p&gt;
</content:encoded></item><item><title>[Interview Question] What is object-oriented programming?</title><link>https://www.traceoflight.dev/en/blog/object-oriented-programming/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/object-oriented-programming/</guid><description>Organizing interview questions about object-oriented programming</description><pubDate>Wed, 12 Jul 2023 07:28:03 GMT</pubDate><content:encoded>&lt;h3&gt;in&lt;/h3&gt;
&lt;p&gt;Yesterday, while interviewing for a job at a major company, I had a situation where I had to answer a question about object-oriented programming that I thought I knew and had organized, but when it came time to answer, I stumbled over it.&lt;/p&gt;
&lt;p&gt;Thanks to this, I thought I had pointed out my weaknesses and decided to take the time to reorganize!&lt;/p&gt;
&lt;p&gt;What is a ### object?&lt;/p&gt;
&lt;p&gt;Let&apos;s start with a general definition&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;General theory: something that actually exists
Computer science: Something created in memory as defined by a class.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Object-oriented languages define the following&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Java: an instance of a class or an array
Python: data that has a property value or behavior.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Classes in Java are not instances, but classes in Python are.&lt;/p&gt;
&lt;h3&gt;Object-oriented programming&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Building interactive programs by defining the roles and relationships of objects.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;We can define it like this.&lt;/p&gt;
&lt;h3&gt;Characteristics of object-oriented languages&lt;/h3&gt;
&lt;h4&gt;abstraction&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Able to derive common features between objects&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The part that defines the class is&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Polymorphism&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Can be called the same for functions that behave in slightly different ways&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Passing interpretation to linked objects for the same command&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Override (overriding internal sources), overload (calling another function with the same name based on parameters)&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Encapsulation&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;You can hide the parts of your implementation without exposing them to the outside world&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If you need to communicate with the outside world, send and receive information via methods&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Inherit from ####&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The inheritance of features from one class by another class&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Allows you to create new classes in addition to those already created&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
</content:encoded></item><item><title>[BOJ 11689, Python] GCD(n, k) = 1</title><link>https://www.traceoflight.dev/en/blog/boj11689/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/boj11689/</guid><description>BOJ 11689, Python solution of the problem &quot;GCD(n, k) = 1&quot;</description><pubDate>Fri, 07 Jul 2023 06:49:25 GMT</pubDate><content:encoded>&lt;h3&gt;Problem link&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;@@tlp8@@&quot;&gt;boj 11689&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Classification&lt;/h3&gt;
&lt;p&gt;Mathematics, Number theory, Eulerian functions&lt;/p&gt;
&lt;h3&gt;Description&lt;/h3&gt;
&lt;p&gt;Recently, I&apos;ve been practicing solving Backzun problems without categorizing them in order to really improve my skills. However, when I come across something like this problem, I get quite a headache.&lt;/p&gt;
&lt;p&gt;In the case of this problem, I initially thought that I should at least try to get it below O(N), since I need to be able to check the numbers up to 10&lt;sup&gt;12&lt;/sup&gt; in 1 second. I thought that if it was a prime factorization, I could just do a normal prime factorization and not have any overlapping numbers, so I used the following code.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;factorize&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;target_number: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;&lt;/span&gt;) -&amp;gt; &lt;span class=&quot;hljs-built_in&quot;&gt;list&lt;/span&gt;:

    result = []
    prime_list = find_prime(target_number)

    now_number = target_number
    &lt;span class=&quot;hljs-keyword&quot;&gt;while&lt;/span&gt; now_number &amp;gt; &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;:
        &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; each_prime &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; prime_list:
            &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; each_prime &amp;gt; now_number:
                &lt;span class=&quot;hljs-keyword&quot;&gt;break&lt;/span&gt;

            &lt;span class=&quot;hljs-keyword&quot;&gt;elif&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;not&lt;/span&gt; now_number % each_prime:
                &lt;span class=&quot;hljs-keyword&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;not&lt;/span&gt; now_number % each_prime:
                    now_number //= each_prime
                result.append(each_prime)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;However, the time complexity was not satisfactory based on this code, so I decided to check the tags and found a new friend in &lt;code&gt;오일러 피 함수&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;As it turns out, the problem itself is a function called&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;φ(n) = {n, the number of natural numbers less than or equal to n that are prime to each other}&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I was able to implement it like this&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;
&lt;span class=&quot;hljs-keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;euler_phi&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;number: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;&lt;/span&gt;) -&amp;gt; &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;:
    &lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;&amp;#x27;&amp;#x27;
    오일러 피 함수를 활용한 자연수 n과 서로소인 수의 갯수를 구하는 함수
    &amp;#x27;&amp;#x27;&amp;#x27;&lt;/span&gt;

    checker = &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;
    result = number

    &lt;span class=&quot;hljs-keyword&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;pow&lt;/span&gt;(checker, &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;) &amp;lt;= number:
        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;not&lt;/span&gt; number % checker:
            &lt;span class=&quot;hljs-keyword&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;not&lt;/span&gt; number % checker:
                number //= checker

            result -= result // checker

        checker += &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;

    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; number &amp;gt; &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;:
        result -= result // number

    &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; result
&lt;/code&gt;&lt;/pre&gt;
&lt;ol&gt;
&lt;li&gt;start at 2 and keep going.&lt;/li&gt;
&lt;li&gt;if the number is divisible, divide it as much as it is divisible. (prime factorization)&lt;/li&gt;
&lt;li&gt;subtract from the resulting number because multiples of that number cannot be prime.&lt;/li&gt;
&lt;li&gt;If there is a number left at the end, subtract it from the resulting number because it is a prime number and multiples of that prime number cannot be prime.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This is where things got a little tricky.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;result -= result // checker&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I wondered why we were removing the divisor from result instead of removing &lt;code&gt;number // checker&lt;/code&gt;, but it makes sense. If we remove the multiples of &lt;code&gt;n&lt;/code&gt;, and then remove the same number of multiples of &lt;code&gt;m&lt;/code&gt;, we end up with 2 multiples of &lt;code&gt;n * m&lt;/code&gt;!&lt;/p&gt;
&lt;p&gt;To handle these duplicates, we subtract the number of multiples of that number from the number that has already been subtracted once.&lt;/p&gt;
&lt;p&gt;Anyway, once you understand how to solve it, it becomes a very easy problem. This seems to be the case with number theory problems, which is great for learning, but a little frustrating because the first approach is always hard...&lt;/p&gt;
&lt;h3&gt;Solution code&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;# GCD(n, k) = 1&lt;/span&gt;

&lt;span class=&quot;hljs-keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;euler_phi&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;target_number: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;&lt;/span&gt;):
    result = target_number
    check_number = &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;

    &lt;span class=&quot;hljs-keyword&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;pow&lt;/span&gt;(check_number, &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;) &amp;lt;= target_number:
        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;not&lt;/span&gt; target_number % check_number:
            &lt;span class=&quot;hljs-keyword&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;not&lt;/span&gt; target_number % check_number:
                target_number //= check_number
            result -= result // check_number
        check_number += &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;

    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; target_number &amp;gt; &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;:
        result -= result // target_number

    &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; result

target = &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt;())
&lt;span class=&quot;hljs-built_in&quot;&gt;print&lt;/span&gt;(euler_phi(target))
&lt;/code&gt;&lt;/pre&gt;
</content:encoded></item><item><title>[Interview Question] Dependency Injection</title><link>https://www.traceoflight.dev/en/blog/dependency-injection/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/dependency-injection/</guid><description>Organizing interview questions about DI</description><pubDate>Thu, 06 Jul 2023 11:46:58 GMT</pubDate><content:encoded>&lt;h3&gt;Dependency injection&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Dependency: a relationship in which an object uses another object.
→ Dependency injection: something that establishes the relationship&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Why do we need dependency injection?&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-java&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;Product&lt;/span&gt; {

	&lt;span class=&quot;hljs-keyword&quot;&gt;private&lt;/span&gt; Apple apple;
    
    &lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;Product&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;()&lt;/span&gt; {
    	&lt;span class=&quot;hljs-built_in&quot;&gt;this&lt;/span&gt;.apple = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;Apple&lt;/span&gt;();
	}

}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In this example, if a class called Product uses the Apple constructor, we are using it without injecting it.
If Product is used, it can be understood as a dependency that comes with Apple. In this case, it&apos;s not a connection between objects, but a relationship between classes.&lt;/p&gt;
&lt;p&gt;Also, if I wanted to use an additional class called &lt;code&gt;Orange&lt;/code&gt;, I would have to make changes to the Product class constructor, which is inflexible.&lt;/p&gt;
&lt;p&gt;In conclusion, to summarize why dependency injection is necessary&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Strong coupling between classes + inflexible code&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;These problems can be solved with dependency injection, so I&apos;d say it&apos;s necessary!&lt;/p&gt;
&lt;h3&gt;Application of the solution&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-java&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;interface&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;Fruit&lt;/span&gt; {

}

&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;Apple&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;implements&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;Fruit&lt;/span&gt; {

}

&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;Product&lt;/span&gt; {

	&lt;span class=&quot;hljs-keyword&quot;&gt;private&lt;/span&gt; Fruit fruit;
    
    &lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;Product&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(Fruit fruit)&lt;/span&gt; {
    	&lt;span class=&quot;hljs-built_in&quot;&gt;this&lt;/span&gt;.fruit = fruit;
    }
    
}

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can see that each class is guaranteed to be independent.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;adding a new Fruit doesn&apos;t change Product&lt;/li&gt;
&lt;li&gt;relationships between objects are formed instead of class relationships&lt;/li&gt;
&lt;/ol&gt;
</content:encoded></item><item><title>[Interview Question] The Structure of the Java Stack &amp; Heap</title><link>https://www.traceoflight.dev/en/blog/java-stack-heap/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/java-stack-heap/</guid><description>Organizing interview questions about Java&apos;s Stack and Heap</description><pubDate>Sun, 02 Jul 2023 17:19:40 GMT</pubDate><content:encoded>&lt;h3&gt;Java Memory Structure&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;/blog/jvm&quot;&gt;See JVM Structure and Principles&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The Java Runtime Data Area we built to run the application is located in memory&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The PC Register, Native Method Stack, and Method areas are shared by all threads.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Only the Stack and Heap regions are thread-specific&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Structure of the Heap&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Eden → Survivor → Old&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The objects are moved in the above format, which is basically the order of creation.&lt;/p&gt;
&lt;h3&gt;The role of the Garbage Collector&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Eden: a place where Java objects are stored as soon as they are created.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Survivor &amp;amp; Old: space where objects are moved based on their degree of reference&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Mark and Sweep: uses the &lt;strong&gt;Mark and Sweep&lt;/strong&gt; algorithm.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Minor Garbage Collector&lt;/h4&gt;
&lt;blockquote&gt;
&lt;p&gt;Responsible for moving the Eden and Survivor regions (Young Generation) based on object references if their memory exceeds the allowable amount.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4&gt;Major Garbage Collector&lt;/h4&gt;
&lt;blockquote&gt;
&lt;p&gt;Responsible for removing all unreferenced objects and reclaiming memory when the memory of the Old region (Tenured Generation) exceeds the allowable limit.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Stops all threads except the one running the garbage collector during the deletion process (&apos;Stop-The-World&apos;)&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Structure of the Stack&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Base Type + Local Variables + Parameters&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;In the case of a parameter, it is used in the form of a reference to an object in the Heap region with the object&apos;s address value.&lt;/p&gt;
&lt;p&gt;→ If the parameter refers to a different object, the address value will only be different, and the object stored in the Heap will not disappear immediately! (Hold until the Major GC is executed)&lt;/p&gt;
&lt;h3&gt;Note&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://coding-factory.tistory.com/828&quot;&gt;Coding Factory&apos;s article&lt;/a&gt;&lt;/p&gt;
</content:encoded></item><item><title>[BOJ 27231, Python] Why I&apos;m Looking Forward to 2023</title><link>https://www.traceoflight.dev/en/blog/boj27231/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/boj27231/</guid><description>Python solution to the BOJ 27231, &quot;Why I&apos;m Looking Forward to 2023&quot; problem</description><pubDate>Fri, 30 Jun 2023 10:32:49 GMT</pubDate><content:encoded>&lt;h3&gt;Problem link&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;@@tlp4@@&quot;&gt;boj 27231&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Classification&lt;/h3&gt;
&lt;p&gt;Brute Force Algorithms, Backtracking&lt;/p&gt;
&lt;h3&gt;Description&lt;/h3&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-11d42ef72dcdad8a-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;It&apos;s nice to see that I&apos;ve been able to solve problems that I couldn&apos;t solve before, so it feels good to know that I&apos;ve improved.&lt;/p&gt;
&lt;p&gt;In the case of this problem, my last attempt was submitted to the competition 5 months ago, but I&apos;ve written down the solution several times in the meantime.&lt;/p&gt;
&lt;p&gt;The reason why there are multiple attempts is because there is only one condition missing, but I&apos;m still not sure why I get a timeout for missing this condition. &lt;s&gt;I hope it&apos;s a reason that I can make up later.&lt;/s&gt; → I thought of this while organizing the content below. Organizing your blog is the best!&lt;/p&gt;
&lt;p&gt;Let me introduce the problem-solving approach&lt;/p&gt;
&lt;p&gt;Bitmask the coordinates between the * + symbols to check for whole numbers&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Set or sort in a list that doesn&apos;t allow duplicates&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Counting numbers up to the number initially entered (because no matter how you slice it, it can never be larger than that number) with increasing squared size&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And here&apos;s where we run into a problem.&lt;/p&gt;
&lt;p&gt;For a number consisting of 0s and 1s, I should output &lt;code&gt;Hello, BOJ 2023!&lt;/code&gt;, because if you break it down to a single number, the value will remain unchanged no matter how many times you square it, but I was simply excluding the case of 1.&lt;/p&gt;
&lt;p&gt;To check this part, I was able to handle the edge case by checking for a single number greater than 2 and printing &lt;code&gt;Hello, BOJ 2023!&lt;/code&gt; if there is no term greater than 2, which is the correct answer.&lt;/p&gt;
&lt;h3&gt;Solving code&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;# 2023년이 기대되는 이유&lt;/span&gt;

&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; sys

&lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt; = sys.stdin.readline

&lt;span class=&quot;hljs-keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;pow_target&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;target_num: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;, exponent: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;&lt;/span&gt;) -&amp;gt; &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;:

    result = &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;

    now_number = target_num

    &lt;span class=&quot;hljs-keyword&quot;&gt;while&lt;/span&gt; now_number:
        result += &lt;span class=&quot;hljs-built_in&quot;&gt;pow&lt;/span&gt;((now_number % &lt;span class=&quot;hljs-number&quot;&gt;10&lt;/span&gt;), exponent)
        now_number //= &lt;span class=&quot;hljs-number&quot;&gt;10&lt;/span&gt;

    &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; result

testcase = &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt;())
result_dict = &lt;span class=&quot;hljs-built_in&quot;&gt;dict&lt;/span&gt;()
output = []

&lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; _ &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(testcase):

    target_number = &lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt;().rstrip(&lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;\n&amp;#x27;&lt;/span&gt;)

    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; result_dict.get(target_number) &lt;span class=&quot;hljs-keyword&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;not&lt;/span&gt; &lt;span class=&quot;hljs-literal&quot;&gt;None&lt;/span&gt;:
        output.append(result_dict[target_number])

    &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;:

        is_under_limit = &lt;span class=&quot;hljs-literal&quot;&gt;True&lt;/span&gt;

        &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; each_element &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;list&lt;/span&gt;(target_number):
            &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;(each_element) &amp;gt; &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;:
                is_under_limit = &lt;span class=&quot;hljs-literal&quot;&gt;False&lt;/span&gt;
                &lt;span class=&quot;hljs-keyword&quot;&gt;break&lt;/span&gt;

        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; is_under_limit:
            result_dict[target_number] = &lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;Hello, BOJ 2023!&amp;#x27;&lt;/span&gt;
            output.append(&lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;Hello, BOJ 2023!&amp;#x27;&lt;/span&gt;)
            &lt;span class=&quot;hljs-keyword&quot;&gt;continue&lt;/span&gt;

        length = &lt;span class=&quot;hljs-built_in&quot;&gt;len&lt;/span&gt;(target_number)

        check_list = []
        check_list.append(&lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;(target_number))

        &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; i &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt; &amp;lt;&amp;lt; length):

            calc_result = &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;

            now_start = &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;
            now_end = &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;

            &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; j &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(length):

                &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; i &amp;amp; (&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt; &amp;lt;&amp;lt; j):
                    now_end = j
                    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; now_end:
                        calc_result += &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;(target_number[now_start : now_end])
                    now_start = now_end
                    
            calc_result += &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;(target_number[now_start : length + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;])

            &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; calc_result &lt;span class=&quot;hljs-keyword&quot;&gt;not&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; check_list:
                check_list.append(calc_result)

        &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;:
            result = &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;

            check_amount = &lt;span class=&quot;hljs-built_in&quot;&gt;len&lt;/span&gt;(check_list)
            check_list.sort()

            max_value = check_list[-&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;]
            pointer = &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;
            counter = &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;

            &lt;span class=&quot;hljs-keyword&quot;&gt;while&lt;/span&gt; pointer &amp;lt; check_amount:
                now_result = pow_target(&lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;(target_number), counter)

                &lt;span class=&quot;hljs-comment&quot;&gt;# 종료 조건 1&lt;/span&gt;
                &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; now_result &amp;gt; max_value:
                    &lt;span class=&quot;hljs-keyword&quot;&gt;break&lt;/span&gt;

                &lt;span class=&quot;hljs-keyword&quot;&gt;while&lt;/span&gt; pointer &amp;lt; check_amount &lt;span class=&quot;hljs-keyword&quot;&gt;and&lt;/span&gt; now_result &amp;gt; check_list[pointer]:
                    pointer += &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;

                &lt;span class=&quot;hljs-comment&quot;&gt;# 종료 조건 2&lt;/span&gt;
                &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; pointer &amp;gt;= check_amount:
                    &lt;span class=&quot;hljs-keyword&quot;&gt;break&lt;/span&gt;

                &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; now_result == check_list[pointer]:
                    result += &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;

                counter += &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;

            result_dict[target_number] = result
            output.append(result)

&lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; result &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; output:
    &lt;span class=&quot;hljs-built_in&quot;&gt;print&lt;/span&gt;(result)

&lt;/code&gt;&lt;/pre&gt;
</content:encoded></item><item><title>[BOJ 13325, Python] Binary Trees</title><link>https://www.traceoflight.dev/en/blog/boj13325/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/boj13325/</guid><description>Python Solution to BOJ 13325, &quot;Binary Tree&quot; Problem</description><pubDate>Wed, 28 Jun 2023 12:58:52 GMT</pubDate><content:encoded>&lt;h3&gt;Problem link&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;@@tlp4@@&quot;&gt;boj 13325&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Classification&lt;/h3&gt;
&lt;p&gt;Dynamic programming, Trees, Dynamic programming in trees&lt;/p&gt;
&lt;h3&gt;Description&lt;/h3&gt;
&lt;p&gt;If you&apos;re like me, you&apos;re the kind of person who sticks with a problem for a long time, even if it&apos;s not solved right away!&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-4b0aee5765d752b7-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;So, along with the problems that I tried but didn&apos;t get, there are problems that I tried hard but couldn&apos;t solve, along with the competition questions...&lt;/p&gt;
&lt;p&gt;To get rid of them, I sometimes read through the questions and chew on them, and I&apos;m so glad I finally found the solution in this post today!&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-5ef200830a30afc7-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I&apos;ve had this problem for 8 months now, since my first attempt, and I&apos;ve tinkered with it a few times since my last attempt, but nothing seemed to work.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;
&lt;span class=&quot;hljs-keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;pre_order_detail&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;graph_dict: &lt;span class=&quot;hljs-built_in&quot;&gt;dict&lt;/span&gt;, target_node: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt; = &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;&lt;/span&gt;) -&amp;gt; &lt;span class=&quot;hljs-built_in&quot;&gt;list&lt;/span&gt;:

    result = [target_node]

    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;len&lt;/span&gt;(graph_dict[target_node]) &amp;gt;= &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;:
        &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; each_element &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; pre_order_detail(graph_dict, graph_dict[target_node][&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;]):
            result.append(each_element)
        result.append(target_node)

    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;len&lt;/span&gt;(graph_dict[target_node]) &amp;gt;= &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;:
        &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; each_element &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; pre_order_detail(graph_dict, graph_dict[target_node][&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;]):
            result.append(each_element)
        result.append(target_node)

    &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; result

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;My original idea was to use a variation of a potential traversal in the form of a recursive function like the one above, taking a picture of the nodes visited, putting them in a stack-like data structure, and then traversing each trunk.&lt;/p&gt;
&lt;p&gt;However, I realized that if I restricted the comparison to trunks from the same parent node, it would be cleaner if I just kept adding the larger of the two values to the parent trunk, and then processed it!&lt;/p&gt;
&lt;p&gt;I later solved and categorized this type of problem as a tree DP. I thought it was very similar to DP.&lt;/p&gt;
&lt;h3&gt;Solving code&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;# 이진 트리&lt;/span&gt;

&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; sys

&lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt; = sys.stdin.readline

tree_height = &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt;())
node_number = &lt;span class=&quot;hljs-built_in&quot;&gt;pow&lt;/span&gt;(&lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;, tree_height + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;)

edges = [&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;] + &lt;span class=&quot;hljs-built_in&quot;&gt;list&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;map&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;, &lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt;().split()))
edge_sum = &lt;span class=&quot;hljs-built_in&quot;&gt;sum&lt;/span&gt;(edges)

now_start = node_number // &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt; - &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;
now_end = node_number - &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;

&lt;span class=&quot;hljs-keyword&quot;&gt;while&lt;/span&gt; now_end:

    &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; i &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;((now_end - now_start) // &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;):

        child_edge = now_start + (&lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt; * i)
        next_node = child_edge // &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;

        edges[next_node] += &lt;span class=&quot;hljs-built_in&quot;&gt;max&lt;/span&gt;(edges[child_edge], edges[child_edge + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;])
        edge_sum += &lt;span class=&quot;hljs-built_in&quot;&gt;abs&lt;/span&gt;(edges[child_edge] - edges[child_edge + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;])

    now_end = now_start
    now_start = now_start // &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;

&lt;span class=&quot;hljs-built_in&quot;&gt;print&lt;/span&gt;(edge_sum)

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is a cleaner code length and time complexity than I initially thought. Now that we have it laid out like this, it&apos;s definitely bottom-up.&lt;/p&gt;
</content:encoded></item><item><title>[Archive] What is IaaS, PaaS, and SaaS?</title><link>https://www.traceoflight.dev/en/blog/iaas-paas-saas/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/iaas-paas-saas/</guid><description>Words you hear often but haven&apos;t explored in depth</description><pubDate>Mon, 26 Jun 2023 05:21:36 GMT</pubDate><content:encoded>&lt;h3&gt;What does &amp;quot;aaS&amp;quot; mean in common parlance?&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Abbreviation for &apos;As a Service&apos;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;It means that a third party provides cloud computing services!&lt;/p&gt;
&lt;h3&gt;What&apos;s the difference?&lt;/h3&gt;
&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;Different infrastructure, platforms, and software are provided as a service.
→ Different management level&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-7a2b2e1c34c6a3d0-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h4&gt;1. IaaS&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Evolved from on-premises infrastructure&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Infrastructure services delivered to the cloud&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Provider is responsible for the management and access to network, servers, virtualization, and storage&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Examples include AWS, Azure, GCP, etc.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;2. PaaS&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Broader scope of responsibility than IaaS&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Allows users to develop, run, and manage their own applications&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Provides an environment for build and deployment&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;3. SaaS&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;All applications are managed by the provider&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Provider manages all maintenance, upgrades, and security of the software&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Note&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://www.redhat.com/ko/topics/cloud-computing/iaas-vs-paas-vs-saas&quot;&gt;IaaS vs. PaaS vs. SaaS&lt;/a&gt;&lt;/p&gt;
</content:encoded></item><item><title>[Interview Question] What is a Connection Pool? (Feat. ChatGPT)</title><link>https://www.traceoflight.dev/en/blog/connection-pool/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/connection-pool/</guid><description>Organizing interview questions about DB Connection Pools</description><pubDate>Sun, 25 Jun 2023 17:05:44 GMT</pubDate><content:encoded>&lt;h3&gt;What is DB Connection Pool?&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Store objects that have already connected to the DB in the pool.
Borrow the connection when a client requests it
When processing is finished, return the connection and save it back to the Pool&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I think you can understand that it is like a connection object that is connected in advance and then retrieved when needed.&lt;/p&gt;
&lt;h3&gt;Why use it?&lt;/h3&gt;
&lt;p&gt;For Java Spring,&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;If you&apos;re using a direct connection to the DB for processing, you can use the&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Need to load the JDBC Driver and get the connection object each time&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Driver loading, object creation, and connection is repeated for each request&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;→ This is very inefficient, so we use Connection Pools to solve these problems.&lt;/p&gt;
&lt;p&gt;+ Other frameworks also use it.&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-bec4f7ed8c564abe-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h3&gt;Features&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Pre-created in the Connection object pool when WAS runs&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Get, write and return objects based on HTTP requests&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;No connection, creation time consumed per Connection request
→ Reduces connection load&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;What if the number of concurrent connections is more than the number of objects in the pool?
→ If there are not enough pre-created connection objects, wait in order until returning&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;Larger pools consume more memory and reduce latency.&lt;/p&gt;
&lt;/blockquote&gt;
</content:encoded></item><item><title>[Side Note] Regarding the location of the main function</title><link>https://www.traceoflight.dev/en/blog/main/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/main/</guid><description>Let&amp;#x27;s move the `main` function to the top</description><pubDate>Sun, 18 Jun 2023 11:50:50 GMT</pubDate><content:encoded>&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;I’ve decided to use the “&lt;code&gt;자투리&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;” category to share brief insights I’ve learned!&lt;/p&gt;
&lt;h3&gt;Placing the main Function at the Top&lt;/h3&gt;
&lt;p&gt;This is something that occurred to me while taking the [CS50](&lt;a href=&quot;https://www.youtube.com/live/ywg7cW0Txs4?feature=share&quot;&gt;https://www.youtube.com/live/ywg7cW0Txs4?feature=share&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;) course. Personally, I tend to write code like this:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;
&lt;span class=&quot;hljs-keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;example&lt;/span&gt;():
	&lt;span class=&quot;hljs-built_in&quot;&gt;print&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;hello&amp;#x27;&lt;/span&gt;)
    
&lt;span class=&quot;hljs-keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;main&lt;/span&gt;():
	example()
    
main()

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For example, I list all the necessary function definitions at the beginning and then add the main function afterward.&lt;/p&gt;
&lt;p&gt;However, I realized that having the main function right at the top definitely makes the code clearer for others to understand.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;
&lt;span class=&quot;hljs-keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;main&lt;/span&gt;():
	example()
    this_function()

&lt;span class=&quot;hljs-keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;example&lt;/span&gt;():
	&lt;span class=&quot;hljs-built_in&quot;&gt;print&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;hello&amp;#x27;&lt;/span&gt;)
    
&lt;span class=&quot;hljs-keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;this_function&lt;/span&gt;():
	&lt;span class=&quot;hljs-built_in&quot;&gt;print&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;function&amp;#x27;&lt;/span&gt;)
    
main()

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I should move the main function—which demonstrates the overall structure of the code—to the top and list the detailed definitions afterward to better illustrate the code’s functionality.&lt;/p&gt;
</content:encoded></item><item><title>SSAFY 8th year review, nothing extraordinary</title><link>https://www.traceoflight.dev/en/blog/ssafy-8/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/ssafy-8/</guid><description>Wrapping up the Samsung Youth SW Academy</description><pubDate>Fri, 16 Jun 2023 17:28:37 GMT</pubDate><content:encoded>&lt;h3&gt;in&lt;/h3&gt;
&lt;p&gt;It&apos;s finally the end of the year-long journey of the 8th edition of the Samsung Youth SW Academy, SSAFY. It&apos;s been a lot of work, but it&apos;s been a lot of fun, so I thought I&apos;d write about it now. If you look at the SSAFY reviews, you&apos;ll see that most of them have completed the program with a grade of excellent or higher, and even received a certificate or two...&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-aee8ee7c7a4b8132-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I think you can think of this review as the story of an SSAFY student who is out there somewhere, not someone who has won many awards and is an excellent SSAFY-type person. I also hope that it can be helpful to those who will take the SSAFY course in the future.&lt;/p&gt;
&lt;h3&gt;입과&lt;/h3&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-442ceb7c6829c573-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-219d272c02689759-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I somehow managed to break through the barrier of SSAFY, which is usually known to be high for non-majors. I passed the self-introduction and failed the interview... but I was notified that I was accepted as a non-major, which is rare, and I joined the Seoul campus. I was able to skip the start camp because I was a last-minute admitted student, but I was told that the start camp is only for those who have been through it.&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-fa0b9011434db360-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;When you get into SSAFY, you are given a name tag, but even the name tag had my name pasted on top of the other early adopters&apos; names... I had to tape it up afterward because it kept falling off.&lt;/p&gt;
&lt;p&gt;Looking back on it now, I think it actually made me work a little harder. I think it kept me motivated and constantly reminded me that the opportunity I was given was priceless!&lt;/p&gt;
&lt;h3&gt;1st semester, Python track&lt;/h3&gt;
&lt;p&gt;In the first semester, there was a Java track and a Python track, and although I knew I wanted to learn Java, I chose to take the Python track. There are many things that I learned in the first semester...&lt;/p&gt;
&lt;p&gt;In the second semester, I think the only things I actually learned and used well were Algorithm, Git, and Python. Even so, Python and Algorithm are overwhelmingly more often used for coding tests than for projects...&lt;/p&gt;
&lt;p&gt;(I&apos;m learning Frontend, but I&apos;m mostly re-learning React, so it doesn&apos;t even exist)&lt;/p&gt;
&lt;p&gt;Still, if you join the track, you can see that almost everyone is passionate about learning, just like SSAFY. I think I spent a lot of time in the class, making studies and studying at the cafe together.&lt;/p&gt;
&lt;p&gt;In my case, I had almost zero experience in programming because all I had was a neat college education, and I thought that I couldn&apos;t be good at everything, so I thought that I needed to choose and focus. So I thought that I should look at the recruitment process first and try to break through it step by step.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Screening → Coding test → Personality interview → Technical interview → Hiring&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I found that most companies stay within this range. As a result, I thought, &lt;strong&gt;“If you can&apos;t pass the coding test, you have no future,”&lt;/strong&gt; and this is the beginning of the algorithmic tech tree...&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-cfc4f764b173e0d0-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I invested a lot of time in studying to improve my algorithmic abilities, but eventually, I virtually exhausted myself after achieving Platinum 5. From that time, I also studied the Java language in order to pass the Samsung Software Competency Assessment Type B, but unfortunately, I ended up not passing. The review is &lt;a href=&quot;/blog/b&quot;&gt;here&lt;/a&gt; and if you get Type B, you will be prioritized for various benefits, experiences, and connections provided by SSAFY, so if you can get it, do it!&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-b2e44c75355b7edc-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;(However, I think it is important to solve even low-level problems steadily so that you don&apos;t lose your sense, so I solved them steadily)&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-8836547a6ac0689c-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;After struggling through the theory and practical exams almost every week, I reached the culminating project. This was a 7-week project that, in hindsight, would have been challenging in the second semester and required &lt;strong&gt;overwhelmingly fewer people and less time&lt;/strong&gt; to accomplish! I&apos;m sure I&apos;ve seen some nice code and pretty applications somewhere, but in the end, the prize went to the team that did what others couldn&apos;t (e.g., deployment).&lt;/p&gt;
&lt;h3&gt;Second semester, one project after another.&lt;/h3&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-00a981c35d4a739d-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;In the second semester, you work on projects the whole time, which I think is the most important part of SSAFY.&lt;/p&gt;
&lt;p&gt;In the first semester, even if you want to apply to a company, if they ask you &amp;quot;What have you done?&amp;quot;, you have nothing to answer, so you have a limited amount of things you can appeal to in your self-introduction or interview, but as you gradually progress through the second semester, regardless of the outcome, if you have faithfully participated in the project, you can say things like &amp;quot;I did such and such, and I had difficulties in such and such, but I improved in such and such a way&amp;quot;!&lt;/p&gt;
&lt;p&gt;If the topic seems to be this or that, but it&apos;s not a specialized project, I&apos;ve been able to work on whatever the team wants without getting stuck on a topic. In my case, I worked on two app development projects and one web development project with mobile specifications. As for the positions, different people may have different things they want to do in the second semester, but I wanted to get experience in all positions, so I went with one backend, one frontend, and one app experience.&lt;/p&gt;
&lt;p&gt;If you&apos;re in the Python track, you&apos;ll mostly be building a wall with Java, and since 99% of the projects in the second semester use Spring Boot, you&apos;ll inevitably end up on the front end, which is where you&apos;ll get the fix for your position. So if you&apos;re a Python track student, it&apos;s a good idea to take Java separately if you know you want to be on the back end. In my case, I took the Java course separately to keep myself open for backend positions, and as a result, I was able to get one backend position.&lt;/p&gt;
&lt;h3&gt;Job Hunting and Interviews&lt;/h3&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-3bc909615076161a-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;While I had the illusion of showing something from semester 1 to semester 2, a small group of prepared people were consistently trying to get in touch with companies, and as a result, had the honor of having a SSAFY escape in between. My first thought when I saw those people was, &amp;quot;I&apos;m not ready yet...&amp;quot;. It won&apos;t be too late when I finish my project,&apos; but as a result, after two semesters, you naturally start to prepare by watching various leaders who escape.&lt;/p&gt;
&lt;p&gt;You may be disappointed to see yourself accepting and completing the second semester certificate while someone else is getting the employee certificate, so you should keep trying. I applied to a lot of places and I ended up accepting the second semester certificate, but I think I&apos;m glad I did.&lt;/p&gt;
&lt;p&gt;Once you have passed the coding test and document screening with the various benefits of SSAFY and the skills you have built up, there is still the interview. You often don&apos;t know where you are lacking until you have both personality and technical interviews, so I think it&apos;s really good if you can experience it during the training period.&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-09b59b4e7d50faf7-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;You definitely get better at interviewing the more you do it. I think that you can&apos;t experience how to deal with the interviewer unless you are in the situation and nervous, so if you are capable of it, keep taking interviews with companies that are lower than the level you actually want so that you can get better results at the company you actually want!&lt;/p&gt;
&lt;h3&gt;Afterward.&lt;/h3&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-0a384db17a2502a8-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;So what are we going to do after SSAFY?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I spent a lot of time thinking about this question and I&apos;m still trying to figure out the answer. Basically, I want to take some time to calmly reflect on the projects I&apos;ve worked on, but I also want to summarize what I&apos;ve learned, and I still want to find a job as soon as possible, so...&lt;/p&gt;
&lt;p&gt;In the end, I think I&apos;ll continue with everything. I believe it&apos;s best to keep building from the bottom up, because the work I&apos;ve done so far won&apos;t disappear. My SSAFY 8th year journey is coming to an end, but my life as a developer doesn&apos;t end here! I believe that better days are waiting for me and I will continue to work hard.&lt;/p&gt;
</content:encoded></item><item><title>2023 LG CNS H1 Recruitment Review</title><link>https://www.traceoflight.dev/en/blog/2023-lg-cns/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/2023-lg-cns/</guid><description>Boom!</description><pubDate>Fri, 16 Jun 2023 08:27:19 GMT</pubDate><content:encoded>&lt;h3&gt;in&lt;/h3&gt;
&lt;p&gt;In the first half of this year, I applied for the LG CNS entry-level recruitment process and made it to the final interview. To conclude, unfortunately, I didn&apos;t get a good result. However, rather than covering up my failures, I would like to write down what I lacked and do better next time. I hope it will be helpful for those who are looking for jobs in the future.&lt;/p&gt;
&lt;h3&gt;Screening&lt;/h3&gt;
&lt;p&gt;I don&apos;t think there was anything unusual about the screening process. The only thing that was unusual was that the self-introduction letter was shorter than other companies. However, there were cases where I was rejected, so I think there was a differentiating factor. If you passed, you could proceed to the coding test.&lt;/p&gt;
&lt;h3&gt;Coding test&lt;/h3&gt;
&lt;p&gt;Overall, I don&apos;t think the difficulty level was too hard. If you can randomly solve the Silver ~ Gold 5 level questions, I think you can do well enough. If I had to give a direction, I think it would be helpful to practice being able to respond to any problem in the field rather than asking for creative algorithms.&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-0050c757a54e8dd4-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;If you&apos;ve solved the problem to a certain level, you can move on to the interview, and I passed with flying colors.&lt;/p&gt;
&lt;h3&gt;First Interview&lt;/h3&gt;
&lt;p&gt;After passing the coding test, I received information about the first round interview. It was basically a video interview, and I think they asked me about the questions in my cover letter and general interview questions. I don&apos;t remember what the interviewer said, but he said that they don&apos;t have high expectations for new hires and don&apos;t evaluate competencies. He also said something after that, but I was nervous and deleted it from my memory. I think if we look at competencies less, we would focus on things like personality, self-introduction verification, integrity, and culture fit!&lt;/p&gt;
&lt;p&gt;On a side note, if you did well on the coding test, you might get a small compliment from the interviewer about the test. I felt good because I paid attention to the counterexamples and edge cases that might be there, and it felt like I got a confirmation of the result.&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-95c1802564fc051e-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I was unfamiliar with the interview, so I was very stiff and clumsy, and I thought I failed... But I got the opportunity to go to the second interview. After all, selling noodles is a science.&lt;/p&gt;
&lt;h3&gt;2nd interview&lt;/h3&gt;
&lt;p&gt;Similar to other corporate screenings, the people who have the power to decide which department you will work in if you are hired come to interview you in person. They introduced themselves at the beginning, but I was too nervous to remember. I think they were trying to make it easy for me, but I only remember that when I thought it was similar to the first interview, they started to ask me technical questions and I was rambling. Finally, I asked him what kind of attitude he would have if he joined the company with ambition, and I remember him smiling and saying some good things. And...&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-306ab2ca84c94e03-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I was honestly heartbroken when I got the answer. However, when I thought about it after the interview, it wasn&apos;t an unreasonable result because there were many things that I was disappointed with. I think that I answered the technical questions I was asked and my level of awareness of the company I applied to too poorly, so I didn&apos;t have any strengths that the interviewer thought would impress them and make them want to hire me.&lt;/p&gt;
&lt;h3&gt;Final thoughts&lt;/h3&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-ca72109624ea74bc-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I&apos;m disappointed because I was the closest I&apos;ve ever been to getting hired in the first half of the program. However, I believe that the report card I received now gives me a direction to move forward, and I am working hard to improve the areas that I was lacking.&lt;/p&gt;
&lt;p&gt;I hope to use this experience as a springboard to become a better version of myself. If I can make them regret not hiring me in the future, that would be a good outcome. In the next CNS recruitment, I will try harder to be &lt;strong&gt;the person who can choose the company&lt;/strong&gt; instead of &lt;strong&gt;the company choosing me&lt;/strong&gt;.&lt;/p&gt;
</content:encoded></item><item><title>[Interview Question] Structure and Principles of the JVM</title><link>https://www.traceoflight.dev/en/blog/jvm/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/jvm/</guid><description>Organizing interview questions about the JVM</description><pubDate>Thu, 15 Jun 2023 16:30:41 GMT</pubDate><content:encoded>&lt;blockquote&gt;
&lt;p&gt;23-06-27 Complete Unfinished Content
23-07-01 Complete and fill in content&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Java Overview&lt;/h3&gt;
&lt;h4&gt;1. Java&apos;s Development Philosophy&lt;/h4&gt;
&lt;blockquote&gt;
&lt;p&gt;Write Once, Run Anywhere&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Aim for a platform-independent language&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Developed with the focus on being able to run code written in the same language on any operating system (sort of cross-platform)&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;2. JDK&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Java Development Kit
It is a Java development tool and includes both JRE and JVM. Unlike users, who basically only need to run programs written in Java, developers need to install the JDK. The JDK includes a compiler.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Java Runtime Environment
The Java Runtime Environment, which includes the Java Class Library, the Java Class Loader, and the JVM. Java code written through the class loader and the library can be combined with the library and run on the JVM.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Java Virtual Machine&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;What is JVM?&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Java Virtual Machine, Java Virtual Machine.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Software that provides an environment for running Java programs.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;Java Code → Compiler → Machine Language&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Builds the Java Runtime Data Area by allocating memory for the application to run.&lt;/p&gt;
&lt;h3&gt;Runtime Data Area&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Heap Area&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Method Area&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The above two areas are shared by all Threads&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;PC Register&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Native Method Stack&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Stack Area&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The above three areas are created at startup and destroyed at termination for each thread.&lt;/p&gt;
&lt;h3&gt;Details of each area&lt;/h3&gt;
&lt;h4&gt;1. Heap&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Space where instances of classes, arrays are stored&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Garbage Collection * Dynamic memory management system&lt;/p&gt;
&lt;h4&gt;2. Method&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Space to store the structure of classes, interfaces&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;3. Stack&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Similar to C&apos;s stack structure, stores local variables and the results of function execution&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;It is responsible for calling and returning functions and has a Stack Frame.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;What is Stack Frame?&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;A delimited space for each function that contains the function&apos;s call information.
Frames are handled in a LIFO fashion
If a frame is added when there is no free space → Stack Overflow occurs
Pointer method using prologue and epilogue to determine stack return location&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4&gt;4. Native Method Stack&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Execution stack of methods written in C, CPP&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Native Method Stack is assigned when executing code&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;May result in StackOverflowError or OutOfMemoryError&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Can dynamically resize the stack&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;5. PC Register&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Each thread has a PC Register&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Records the address of the instruction when the thread executes the currently assigned instruction&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Steadily fluctuates the value from instruction to instruction to execute the pointed-to value&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Notes&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-2.html#jvms-2.1&quot;&gt;JVM Document&lt;/a&gt;
&lt;a href=&quot;https://m.blog.naver.com/goreng2/221770110714&quot;&gt;고랭이님의 블로그&lt;/a&gt;
&lt;a href=&quot;https://velog.io/@sgwon1996/JAVA%EC%9D%98-%EB%8F%99%EC%9E%91-%EC%9B%90%EB%A6%AC%EC%99%80-JVM-%EA%B5%AC%EC%A1%B0&quot;&gt;sgwon1996&apos;s velog&lt;/a&gt;&lt;/p&gt;
</content:encoded></item><item><title>[Interview Question] What is DB Index?</title><link>https://www.traceoflight.dev/en/blog/db-index/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/db-index/</guid><description>Organizing interview questions for database indexes</description><pubDate>Tue, 13 Jun 2023 15:20:25 GMT</pubDate><content:encoded>&lt;blockquote&gt;
&lt;p&gt;Data structures to speed up searches of database tables&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Advantages of using indexes&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Improved performance due to faster table lookups&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Can reduce system load&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Disadvantages of using indexes&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Requires additional storage space for DB indexing&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Additional work and overhead for DB management&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Index management&lt;/h3&gt;
&lt;p&gt;Because indexes must always be kept up-to-date and sorted to quickly find the desired value, hanging an index on a property whose data is frequently modified can result in a performance penalty due to overhead.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;INSERT: Adds an index of the inserted data on insertion&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;DELETE: indexes on deleted data should be disabled&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;UPDATE: Disable existing indexes + add indexes for updated data&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Data structures used&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;B+ Tree&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;B Tree enhancement specification&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Store data only in leaf nodes&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Leaf nodes have a linked list between them&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Hash Table&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;Stores data as key - value pairs
Data can be navigated in a very short amount of time
Not often used due to inequality operations (sort X)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Classification of indexes&lt;/h3&gt;
&lt;h4&gt;1. Classification by Key&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Primary index: contains primary key (order of key = order of records)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Secondary index: without primary key (order of keys != order of records)&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;2. Classification based on file organization&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Focused index&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Non-centralized indexes&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;3. Categorize by data scope&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Dense indexes&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Sparse indexes&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Note&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://brunch.co.kr/@skeks463/25&quot;&gt;brunchstory by Nathan&lt;/a&gt;&lt;/p&gt;
</content:encoded></item><item><title>[1Day-1CS] Devices that handle each layer</title><link>https://www.traceoflight.dev/en/blog/1day-1cs-e4320ddf/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/1day-1cs-e4320ddf/</guid><description>1CS per day, a quick rundown of the devices that handle each layer</description><pubDate>Mon, 05 Jun 2023 15:08:16 GMT</pubDate><content:encoded>&lt;blockquote&gt;
&lt;p&gt;2023-06-18 Merge content from previous posts for content consistency&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Devices that handle the application layer&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;L7 switch: also known as a load balancer, a device that balances the load on servers&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Switch: A telecommunications network device that connects multiple devices and mediates data communications, sending electrical signals only to the connected ports to transmit data.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Aimed at increasing the amount of traffic a system can handle&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Distribute traffic based on URLs, servers, caches, cookies, etc.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Has filtering capabilities to keep out unnecessary external data&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Allows you to monitor traffic&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;= Health Check excludes failed servers from traffic distribution via a health check&lt;/p&gt;
&lt;h3&gt;Difference between L4 and L7 switches&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;L4 switches are devices that handle the transport layer and cannot be used for streaming-related services.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Message-based unawareness, IP &amp;amp; Port based traffic distribution&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In cloud services, load balancing with L7 switches is done with ALB (Application Load Balancer) component and load balancing with L4 switches is done with NLB (Network Load Balancer) component&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Health Check&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Sending requests to the server repeatedly by setting the transmission cycle and number of retransmissions, etc.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Appropriate enough to not overload the server&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Sending requests in different ways and determining if they are processed correctly.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Server redundancy with load balancers&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Provide virtual IPs based on 2 or more servers and provide stable services based on them&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Server redundancy is necessary because the service must continue even if a specific server fails.&lt;/p&gt;
&lt;h3&gt;Devices that handle the Internet layer&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Router: connects, divides, and separates multiple networks.
L3 switch: L2 switch + router&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Devices that handle the data link layer&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;L2 switch: Manages the Mac addresses of devices, sends packets, etc.
Bridge: a telecommunications network connection device that allows two local area networks to interconnect&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Devices that handle the physical layer&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Network Interface Card (NIC): LAN card, uniquely identifyingMac addresses reside here.
Repeater: Amplifies an incoming signal and forwards it to the other end.
AP: a device that copies packets; connects a wired LAN to a wireless network.&lt;/p&gt;
&lt;/blockquote&gt;
</content:encoded></item><item><title>[Interview Question] Frameworks and Libraries (Feat. ChatGPT)</title><link>https://www.traceoflight.dev/en/blog/framework-library/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/framework-library/</guid><description>Organizing interview questions about Frameworks and Libraries</description><pubDate>Sat, 03 Jun 2023 13:45:20 GMT</pubDate><content:encoded>&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;This time, I was asked this question for the first time in an interview, and although I honestly thought I knew the answer, I couldn&apos;t answer it clearly and ended up giving an alumni answer... So, I&apos;m writing this article to know a little more clearly, thinking that I shouldn&apos;t do that next time!&lt;/p&gt;
&lt;h3&gt;Library&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;A program designed to perform a specific function by modularizing functions that can be used commonly in development.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Framework&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;A collection of classes and libraries with multiple functions that are put together to achieve a specific result.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;ChatGPT&apos;s answer&lt;/h3&gt;
&lt;p&gt;The above definitions are what I personally thought were close to the correct answers after reading several articles. However, something felt incomplete and I wanted a more detailed answer, so I decided to utilize ChatGPT!&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Definition of Library
&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-63d37d80c7d7a66e-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Definition of Framework
&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-f8277c02067f5cf0-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;So what&apos;s the difference?&lt;/h3&gt;
&lt;p&gt;If we go back to the answer above and look at Frameworks and Libraries, we can see that the&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Library&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;Collection of reusable code and resources
Organized into functions, classes, methods, data types, etc.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Framework&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;A structured framework or platform for developing software.
Consists of predefined code and libraries&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;It&apos;s hard not to look at this and wonder. If frameworks can contain libraries, why can&apos;t libraries contain frameworks?&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-27fca29bce6050ea-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;As expected, it turns out that frameworks can contain libraries, but not vice versa. The article also highlights an important difference between frameworks and libraries.&lt;/p&gt;
&lt;p&gt;It&apos;s &lt;strong&gt;the control of code flow&lt;/strong&gt;. In the case of a library, &lt;strong&gt;the developer calls the library&apos;s functions and uses them&lt;/strong&gt;, but in the case of a framework, &lt;strong&gt;the developer&apos;s methods are called by the framework&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;The form that appears in a framework is called IoC (Inversion of Control). Since it is related to Dependency Injection, I won&apos;t write much about it because I think there will be something else to write about.&lt;/p&gt;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A library is a collection of reusable code and resources, while a framework is a structural framework or platform for development. They generally work similarly in terms of functionality, so the difference is in how they are used.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Frameworks can contain libraries, but libraries cannot contain frameworks. Control of the code flow is in the hands of the framework and the developer in the hands of the library, so it&apos;s generally not possible for a developer to modify a framework, while a library can be customized by the developer as needed.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;See also&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://curryyou.tistory.com/363&quot;&gt;Kareyou&apos;s Blog&lt;/a&gt;
ChatGPT 3.5&lt;/p&gt;
</content:encoded></item><item><title>[Interview Question] What is the difference between Fork and Exec?</title><link>https://www.traceoflight.dev/en/blog/fork-exec/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/fork-exec/</guid><description>Organizing interview questions about fork and exec in Processes</description><pubDate>Wed, 31 May 2023 07:48:53 GMT</pubDate><content:encoded>&lt;h3&gt;What do fork() and exec() have in common?&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Used by one process to execute another process&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;fork()&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Allocates memory for a new process&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;process is added (we have one process with a different PID)&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;exec()&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;does not allocate additional memory for the new process&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Load the new process by overwriting the existing process (same PID)&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;→ The new process will work after the call, so programs after the execution point of the existing program will not work&lt;/p&gt;
&lt;h3&gt;Notes.&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://woochan-autobiography.tistory.com/207#2.%20fork(),%20exec()%EC%9D%98%20%EC%B0%A8%EC%9D%B4%EC%A0%90&quot;&gt;U-chan Seon&apos;s Blog&lt;/a&gt;&lt;/p&gt;
</content:encoded></item><item><title>[BOJ 2887, Python] Planetary Tunnels</title><link>https://www.traceoflight.dev/en/blog/boj2887/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/boj2887/</guid><description>Python Solution to BOJ 2887, &quot;Planetary Tunnel&quot; Problem</description><pubDate>Tue, 30 May 2023 15:33:18 GMT</pubDate><content:encoded>&lt;h3&gt;Problem link&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/2887&quot;&gt;boj 2887&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Classification&lt;/h3&gt;
&lt;p&gt;Graph theory, Sorting, Minimal spanning trees&lt;/p&gt;
&lt;h3&gt;Description&lt;/h3&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-edb2ff1f13cf5892-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I&apos;m surprised that it&apos;s been more than half a year since I first encountered this problem... but I thought it was worth documenting because it was solved with a solution that made sense to me, even though I&apos;ve been neglecting Platinum issues lately.&lt;/p&gt;
&lt;p&gt;To solve this problem formally, you can use a combination of the Union Find + Kruskal algorithm, which picks two coordinates out of a maximum of 100,000, lists their values from the smallest to the largest, and then includes the smallest trunk line.&lt;/p&gt;
&lt;p&gt;However, this would result in a solution time of 10&lt;sup&gt;5&lt;/sup&gt; * 10&lt;sup&gt;5&lt;/sup&gt;, which is roughly 10 billion cases, which would require a solution time of about 100 seconds, making it an infeasible solution method.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Tip: If we consider 1 second per 100 million operations, it is easy to compute!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;So the key to this problem is how to reduce the number of cases from O(N&lt;sup&gt;2&lt;/sup&gt;) to O(N).&lt;/p&gt;
&lt;p&gt;To summarize, in the current problem, when building a spanning tree for an arbitrary point, we don&apos;t need to consider points other than neighboring points.&lt;/p&gt;
&lt;p&gt;Consider a situation where we have arbitrary points A, B, and we need to connect them to a point C.&lt;/p&gt;
&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;If the difference between their x-values (|X&lt;sub&gt;A&lt;/sub&gt; - X&lt;sub&gt;B&lt;/sub&gt;|) is the smallest value less than y, z
→ Assume that the x-value of the point C lies between the x-values of A and B.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ol&gt;
&lt;li&gt;if |X&lt;sub&gt;A&lt;/sub&gt; - X&lt;sub&gt;C&lt;/sub&gt;| + |X&lt;sub&gt;B&lt;/sub&gt; - X&lt;sub&gt;C&lt;/sub&gt;|, then the difference does not exist&lt;/li&gt;
&lt;li&gt;Any arbitrary |X&lt;sub&gt;A&lt;/sub&gt; - X&lt;sub&gt;B&lt;/sub&gt;| that retains |X&lt;sub&gt;A&lt;/sub&gt; - X&lt;sub&gt;C&lt;/sub&gt;| or |X&lt;sub&gt;B&lt;/sub&gt; - X&lt;sub&gt;C&lt;/sub&gt;| that further connects C &lt;strong&gt;must be larger than the existing spanning tree&lt;/strong&gt; → &lt;strong&gt;cannot exist as a counterexample&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;
&lt;p&gt;Thus, if a trunk line connecting two arbitrary points is included in the minimal spanning tree of the current problem, it proves that the two points must be adjacent!&lt;/p&gt;
&lt;p&gt;Solving this proof is the key, and I don&apos;t think the rest of the problem is much different from a typical union find problem.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;Addition) I was getting timeouts when using PriorityQueue instead of heapq, and I was able to find an answer to that issue.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/36991716/whats-the-difference-between-heapq-and-priorityqueue-in-python&quot;&gt;What&apos;s the difference between heapq and PriorityQueue in python?&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The answer is that PriorityQueue is slower because it guarantees thread safety.&lt;/p&gt;
&lt;h3&gt;Solution code&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;# 행성 터널&lt;/span&gt;

&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; sys
&lt;span class=&quot;hljs-keyword&quot;&gt;from&lt;/span&gt; heapq &lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; heappush, heappop

&lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt; = sys.stdin.readline

&lt;span class=&quot;hljs-keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;check_union&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;union_info: &lt;span class=&quot;hljs-built_in&quot;&gt;list&lt;/span&gt;, now_target: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;&lt;/span&gt;) -&amp;gt; &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;:
    &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;&amp;quot;&amp;quot;
    해당 노드의 현재 유니온을 조회하는 함수
    &amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;

    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; union_info[now_target] == -&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;:
        union_info[now_target] = now_target

    &lt;span class=&quot;hljs-keyword&quot;&gt;elif&lt;/span&gt; union_info[now_target] != now_target:
        union_info[now_target] = check_union(union_info, union_info[now_target])

    &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; union_info[now_target]

&lt;span class=&quot;hljs-keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;make_union&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;union_info: &lt;span class=&quot;hljs-built_in&quot;&gt;list&lt;/span&gt;, target_1: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;, target_2: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;&lt;/span&gt;) -&amp;gt; &lt;span class=&quot;hljs-literal&quot;&gt;None&lt;/span&gt;:
    &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;&amp;quot;&amp;quot;
    두 점이 같은 유니온인지 확인하고 아니라면 합쳐주는 함수
    &amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;
    union_1 = check_union(union_info, target_1)
    union_2 = check_union(union_info, target_2)

    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; union_1 == union_2:
        &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hljs-literal&quot;&gt;True&lt;/span&gt;

    &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;:
        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; union_1 &amp;gt; union_2:
            union_info[union_1] = union_2
        &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;:
            union_info[union_2] = union_1

        &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hljs-literal&quot;&gt;False&lt;/span&gt;

planet_number = &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt;())
coord_list = []

&lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; i &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(planet_number):
    coord_list.append([i] + &lt;span class=&quot;hljs-built_in&quot;&gt;list&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;map&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;, &lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt;().split())))

cost_queue = []

&lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; i &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;4&lt;/span&gt;):
    coord_list.sort(key=&lt;span class=&quot;hljs-keyword&quot;&gt;lambda&lt;/span&gt; x: x[i])
    &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; j &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(planet_number - &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;):
        heappush(
            cost_queue,
            (
                coord_list[j + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;][i] - coord_list[j][i],
                (coord_list[j][&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;], coord_list[j + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;][&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;]),
            ),
        )

union_info = [-&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; _ &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(planet_number)]

total_length = &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;
line_number = &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;

&lt;span class=&quot;hljs-keyword&quot;&gt;while&lt;/span&gt; cost_queue:
    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; line_number == planet_number - &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;:
        &lt;span class=&quot;hljs-keyword&quot;&gt;break&lt;/span&gt;

    now_length, nodes = heappop(cost_queue)
    node_a, node_b = nodes

    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;not&lt;/span&gt; make_union(union_info, node_a, node_b):
        total_length += now_length
        line_number += &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;

&lt;span class=&quot;hljs-built_in&quot;&gt;print&lt;/span&gt;(total_length)

&lt;/code&gt;&lt;/pre&gt;
</content:encoded></item><item><title>[Interview Question] Difference between Process and Thread, Multi Thread</title><link>https://www.traceoflight.dev/en/blog/process-thread/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/process-thread/</guid><description>Organizing interview questions about the difference between Processes and Threads</description><pubDate>Mon, 29 May 2023 17:44:03 GMT</pubDate><content:encoded>&lt;blockquote&gt;
&lt;p&gt;&lt;s&gt;Still writing!&lt;/s&gt;
&lt;s&gt;23. 05. 30. writing completed&lt;/s&gt; → 23. 06. 09. add content&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Program&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;A set of executable instructions written for a computer to perform a specific task.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;It&apos;s defined in many different ways, but this is how I understood it when I read it! The reason I checked the definition of a program first is because the definition of a process is a narrower scope program.&lt;/p&gt;
&lt;h3&gt;Process&lt;/h3&gt;
&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&apos;instance&apos;&lt;/strong&gt; of a &lt;strong&gt;&apos;running&apos;&lt;/strong&gt; program (used almost interchangeably with Task)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;An operating system-based unit of work that runs in memory.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Consumes a lot of time and resources to create (high overhead)&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;p&gt;I think the unique part is that it is possible to have multiple instances of a program simultaneously, rather than the program itself.&lt;/p&gt;
&lt;h3&gt;Thread&lt;/h3&gt;
&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A CPU-based unit of execution that performs work within a process.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Every processor has at least one thread&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Threads have their own registers and stack&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Heap memory space is shared&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;h3&gt;So what&apos;s the difference between the two?&lt;/h3&gt;
&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;Processes can be viewed as a larger categorical unit&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;p&gt;However, I think this would be a very comprehensive answer if I simply left it at that, so I&apos;ve added some additional clarification by referring to some well-organized articles!&lt;/p&gt;
&lt;h3&gt;How it works&lt;/h3&gt;
&lt;h4&gt;1. For Process&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The process is allocated a separate memory area by the operating system when it runs.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The memory area has the following format: Code/Data/Stack/Heap&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Cannot access memory regions of other processes&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;2. For Threads&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Process&apos;s Stack region is partitioned and has its own region&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The rest of the Code, Data, and Heap areas are shared&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Errors in one process don&apos;t spread to other processes&apos; regions&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;But if one thread fails, all threads terminate&lt;/strong&gt;.
→ because there are shared memory regions&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;What is the difference between Process and Thread?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A process is a program in dynamic use, while a thread is a unit of execution of some kind of work.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A process contains at least one thread&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Processes do not typically share memory space, but threads do.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Processes go down alone on each failure, threads go down all within the same process&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h3&gt;+ About Multi-Thread&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Multiple threads performing tasks simultaneously within one process.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4&gt;Context Switching (Context Switching)&lt;/h4&gt;
&lt;blockquote&gt;
&lt;p&gt;By default, the maximum number of tasks that can be processed simultaneously is the number of cores.
If more threads are running than the number of cores, each core alternately performs multiple tasks.
Saving and reading the current state of the task or the data required for the next task when the thread is switched.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4&gt;Advantages and disadvantages of multithreading and processes&lt;/h4&gt;
&lt;h5&gt;1) Advantages of Multi-Threading&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;System calls for process creation and resource allocation are sleepy, allowing for efficient resource management.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Less processing cost for sending and receiving data between threads because they share memory space except for the stack within one process.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Reduced program response time due to less complex communication methods between threads.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h5&gt;2) Disadvantages of Multi-Threading&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Increased debugging difficulty and design difficulty&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Cannot control threads from other processes&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Synchronization problems due to memory sharing (accessing the same resources at the same time)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Problems with a thread affect the entire process&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h5&gt;3) Advantages of multiprocessing&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;If something goes wrong in a process, the impact doesn&apos;t spread outside that process&lt;/li&gt;
&lt;/ul&gt;
&lt;h5&gt;4) Disadvantages of Multi-Process&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;High overhead in context exchange&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Inter-process communication is more difficult and complex than inter-thread communication&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Note&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://ko.wikipedia.org/wiki/&quot;&gt;Wikipedia&apos;s entry on processes and threads&lt;/a&gt;
&lt;a href=&quot;https://velog.io/@raejoonee/%ED%94%84%EB%A1%9C%EC%84%B8%EC%8A%A4%EC%99%80-%EC%8A%A4%EB%A0%88%EB%93%9C%EC%9D%98-%EC%B0%A8%EC%9D%B4&quot;&gt;Difference between process and thread by raejoonee&lt;/a&gt;
&lt;a href=&quot;https://gmlwjd9405.github.io/2018/09/14/process-vs-thread.html&quot;&gt;Difference between process and thread by heejeong Kwon&lt;/a&gt;&lt;/p&gt;
</content:encoded></item><item><title>[CI/CD] Flow from Instance to DooD Deployment (Feat. Nginx, Jenkins)</title><link>https://www.traceoflight.dev/en/blog/ci-cd-dood-feat-nginx-jenkins/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/ci-cd-dood-feat-nginx-jenkins/</guid><description>Solidifying your deployment foundation with Docker and Nginx</description><pubDate>Sat, 27 May 2023 14:55:17 GMT</pubDate><content:encoded>&lt;blockquote&gt;
&lt;p&gt;23-06-16 Modified path for volume mounting clarity
23-07-05 Adjust settings for development convenience&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;/blog/cicd-docker-jenkins-git-webhook&quot;&gt;[CI/CD] Organizing automatic deployment of FastAPI server using Docker + Jenkins + Git Webhook&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The reason for writing this post is that the last post above contains what I initially tried to learn, but I wanted to fix what needs to be fixed, polish what needs to be polished, and complete it in one neat post.&lt;/p&gt;
&lt;p&gt;I&apos;ve gained a certain amount of know-how and structured my deployment tasks since the last time and helped people around me deploy, so I hope I can keep a record of it and use it as a consistent process for the next time I deploy! If you follow this post in order, I don&apos;t think you&apos;ll find it difficult to deploy.&lt;/p&gt;
&lt;h3&gt;Additional things I&apos;ve learned since part 1&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Why implement out of Docker rather than in Docker?&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;By default, Docker discourages allowing commands to be executed on top of Docker containers&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Docker in Docker grants powerful privileges to the Docker-installed container, which can be a security risk&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Docker out of Docker allows you to run Docker commands through a socket share with Docker outside of the container.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;What about using the Docker API?&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;Actually, that&apos;s what I used to solve the problem in part 1, and it worked.
But if you have a successful build out of Docker, I don&apos;t think you&apos;ll need it much in your CI/CD process...&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;hr&gt;
&lt;p&gt;&lt;strong&gt;Something about the API that I thought was too vague to write about separately, so I just wrote it down&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Docker uses a REST API to communicate between the engine and the client, which is mostly unused, but is available.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;  docker --tlsverify --tlscacert=/.docker/ca.pem \
  --tlscert=/.docker/cert.pem --tlskey=/.docker/key.pem \
  -H={server_ip}:{port_number} &lt;span class=&quot;hljs-built_in&quot;&gt;exec&lt;/span&gt; nginx \
  sed -i &lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;4s/.*$/ server {container}:8000;/&amp;#x27;&lt;/span&gt; /etc/nginx/sites-available/default.conf
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This code modifies the contents of an Nginx configuration file located on an arbitrary server via a Docker Client with a TLS certificate.
It communicates with the Daemon (Docker Engine) through the port on that server via the -H command, and the rest of the code is a procedure to secure access via the certificate.&lt;/p&gt;
&lt;p&gt;If you leave a port open without using a certificate, someone can crash your container through that port!&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-fb3d711504538106-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Real world experience with container jamming. I left a common port used by Docker open without authentication security...&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Securing via certificates is a must, and if for some unavoidable reason you can&apos;t, it&apos;s imperative to limit the commands that can be run through that port.&lt;/p&gt;
&lt;p&gt;See [Docker API Documents] (&lt;a href=&quot;https://docs.docker.com/engine/api/v1.43/&quot;&gt;https://docs.docker.com/engine/api/v1.43/&lt;/a&gt;) for more details!&lt;/p&gt;
&lt;hr&gt;
&lt;h3&gt;Procedure for building an All in One deployment base&lt;/h3&gt;
&lt;h4&gt;1. Access and update instances&lt;/h4&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;ssh -i {secure shell key 경로} {사용자 이름}@{IP 주소}

&lt;span class=&quot;hljs-built_in&quot;&gt;sudo&lt;/span&gt; apt-get update
&lt;span class=&quot;hljs-built_in&quot;&gt;sudo&lt;/span&gt; apt-get upgrade
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you are setting up ubuntu, the username is often ubuntu.&lt;/p&gt;
&lt;h4&gt;2. Firewall settings&lt;/h4&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;hljs-built_in&quot;&gt;sudo&lt;/span&gt; ufw allow ssh    &lt;span class=&quot;hljs-comment&quot;&gt;# ssh를 22로 대체할 수 있다.&lt;/span&gt;
&lt;span class=&quot;hljs-built_in&quot;&gt;sudo&lt;/span&gt; ufw allow http   &lt;span class=&quot;hljs-comment&quot;&gt;# http를 80으로 대체할 수 있다.&lt;/span&gt;
&lt;span class=&quot;hljs-built_in&quot;&gt;sudo&lt;/span&gt; ufw allow https  &lt;span class=&quot;hljs-comment&quot;&gt;# https를 443으로 대체할 수 있다.&lt;/span&gt;

&lt;span class=&quot;hljs-built_in&quot;&gt;sudo&lt;/span&gt; ufw &lt;span class=&quot;hljs-built_in&quot;&gt;enable&lt;/span&gt; 	  &lt;span class=&quot;hljs-comment&quot;&gt;# 방화벽 가동&lt;/span&gt;
&lt;span class=&quot;hljs-built_in&quot;&gt;sudo&lt;/span&gt; ufw status 	  &lt;span class=&quot;hljs-comment&quot;&gt;# 방화벽 상태 확인&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you are using the cloud, you will probably have to open the port in the cloud&apos;s own port security settings by default.
UFW is Ubuntu&apos;s firewall, and if it is turned off when you initially set it up, you need to authorize the port and turn it on.
With the above settings, you can turn on the firewall with the default HTTP(80), HTTPS(443), and SSH(22) ports open.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;It is recommended to turn on the port allow setting first. If you turn on the firewall with SSH port 22 closed, you will not be able to connect to it.&lt;/strong&gt;&lt;/p&gt;
&lt;h4&gt;3. Install Docker and Docker Compose&lt;/h4&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;# Docker 설치&lt;/span&gt;

&lt;span class=&quot;hljs-built_in&quot;&gt;sudo&lt;/span&gt; apt-get update
&lt;span class=&quot;hljs-built_in&quot;&gt;sudo&lt;/span&gt; apt-get install ca-certificates curl gnupg

&lt;span class=&quot;hljs-built_in&quot;&gt;sudo&lt;/span&gt; install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | &lt;span class=&quot;hljs-built_in&quot;&gt;sudo&lt;/span&gt; gpg --dearmor -o /etc/apt/keyrings/docker.gpg
&lt;span class=&quot;hljs-built_in&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;chmod&lt;/span&gt; a+r /etc/apt/keyrings/docker.gpg

&lt;span class=&quot;hljs-built_in&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;deb [arch=&lt;span class=&quot;hljs-subst&quot;&gt;$(dpkg --print-architecture)&lt;/span&gt; signed-by=/etc/apt/keyrings/docker.gpg] \
https://download.docker.com/linux/ubuntu \
&lt;span class=&quot;hljs-subst&quot;&gt;$(. /etc/os-release &amp;amp;&amp;amp; echo &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;&lt;span class=&quot;hljs-variable&quot;&gt;$VERSION_CODENAME&lt;/span&gt;&amp;quot;&lt;/span&gt;)&lt;/span&gt; stable&amp;quot;&lt;/span&gt; | \
&lt;span class=&quot;hljs-built_in&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;tee&lt;/span&gt; /etc/apt/sources.list.d/docker.list &amp;gt; /dev/null

&lt;span class=&quot;hljs-built_in&quot;&gt;sudo&lt;/span&gt; apt-get update
&lt;span class=&quot;hljs-built_in&quot;&gt;sudo&lt;/span&gt; apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

&lt;span class=&quot;hljs-comment&quot;&gt;# Docker Compose 설치&lt;/span&gt;

&lt;span class=&quot;hljs-built_in&quot;&gt;sudo&lt;/span&gt; apt install docker-compose
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;a href=&quot;https://docs.docker.com/engine/install/ubuntu/&quot;&gt;Ubuntu Docker Installation Documents&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;As of May 2023, I&apos;ve culled only what I needed from the Documents.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;hljs-built_in&quot;&gt;sudo&lt;/span&gt; usermod -aG docker &lt;span class=&quot;hljs-variable&quot;&gt;$USER&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This command allows you to use docker commands without sudo.
If you don&apos;t include it, you will get &lt;code&gt;/var/run/docker.sock: connect: permission denied&lt;/code&gt;.&lt;/p&gt;
&lt;h4&gt;4. Write docker-compose.yml&lt;/h4&gt;
&lt;pre&gt;&lt;code class=&quot;language-yml&quot;&gt;&lt;span class=&quot;hljs-attr&quot;&gt;version:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;3.8&amp;#x27;&lt;/span&gt;

&lt;span class=&quot;hljs-attr&quot;&gt;networks:&lt;/span&gt;
  {&lt;span class=&quot;hljs-string&quot;&gt;원하는&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;네트워크&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;이름&lt;/span&gt;}&lt;span class=&quot;hljs-string&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;driver:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;bridge&lt;/span&gt;

&lt;span class=&quot;hljs-attr&quot;&gt;services:&lt;/span&gt;

  &lt;span class=&quot;hljs-comment&quot;&gt;# Jenkins Container 설정&lt;/span&gt;
  &lt;span class=&quot;hljs-attr&quot;&gt;jenkins:&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;container_name:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;jenkins&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;image:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;jenkins/jenkins:lts&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;restart:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;unless-stopped&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;ports:&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;{원하는 포트 번호}:8080&amp;quot;&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;volumes:&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;./mount/jenkins:/var/jenkins_home&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;/var/run/docker.sock:/var/run/docker.sock&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;user:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;root&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;environment:&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;TZ=Asia/Seoul&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;networks:&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; {&lt;span class=&quot;hljs-string&quot;&gt;원하는&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;네트워크&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;이름&lt;/span&gt;}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We wrote the deployment pipeline tool as if it were utilizing Jenkins.&lt;/p&gt;
&lt;p&gt;If you don&apos;t have a network to add, you can leave out the network part altogether and proceed with the volume bindings for the sockets to use out of Docker. You can set the time zone or additional volume bindings as needed.&lt;/p&gt;
&lt;h4&gt;5. Set up DNS for the domain you want to use&lt;/h4&gt;
&lt;p&gt;Different domain providers use different methods. You&apos;ll need to look at your domain provider&apos;s registration instructions and go through the process of registering the IP of the server you&apos;ll be using and associating it with your domain.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.whatsmydns.net/&quot;&gt;What&apos;s My DNS&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It&apos;s not instantaneous, it takes time for DNS servers to reflect it. I&apos;ve attached a site above where you can easily check how much it&apos;s spread.&lt;/p&gt;
&lt;h4&gt;6. Issuing a certificate using Let&apos;s Encrypt&lt;/h4&gt;
&lt;h5&gt;1) docker-compose.yml&lt;/h5&gt;
&lt;pre&gt;&lt;code class=&quot;language-yml&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;# Nginx 설정&lt;/span&gt;
  &lt;span class=&quot;hljs-attr&quot;&gt;nginx:&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;container_name:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;nginx&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;image:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;nginx:latest&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;restart:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;unless-stopped&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;volumes:&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;./mount/nginx/nginx.conf:/etc/nginx/nginx.conf&lt;/span&gt; 			&lt;span class=&quot;hljs-comment&quot;&gt;# Nginx 설정을 위한 바인딩&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;./mount/nginx/sites-available:/etc/nginx/sites-available&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;./data/certbot/conf:/etc/letsencrypt&lt;/span&gt;				&lt;span class=&quot;hljs-comment&quot;&gt;# 인증서 공유를 위한 바인딩&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;./data/certbot/www:/var/www/certbot&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;ports:&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;80&lt;/span&gt;&lt;span class=&quot;hljs-string&quot;&gt;:80&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;443&lt;/span&gt;&lt;span class=&quot;hljs-string&quot;&gt;:443&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;environment:&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;TZ=Asia/Seoul&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;networks:&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; {&lt;span class=&quot;hljs-string&quot;&gt;원하는&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;네트워크&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;이름&lt;/span&gt;}

  &lt;span class=&quot;hljs-comment&quot;&gt;# Certbot 컨테이너 설정&lt;/span&gt;
  &lt;span class=&quot;hljs-attr&quot;&gt;certbot:&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;container_name:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;certbot&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;image:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;certbot/certbot&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;restart:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;unless-stopped&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;volumes:&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;./data/certbot/conf:/etc/letsencrypt&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;./data/certbot/www:/var/www/certbot&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;environment:&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;TZ=Asia/Seoul&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Add this to docker-compose.yml and don&apos;t process it.&lt;/p&gt;
&lt;h5&gt;2) mount/sites-available/default.conf&lt;/h5&gt;
&lt;pre&gt;&lt;code class=&quot;language-nginx&quot;&gt;&lt;span class=&quot;hljs-section&quot;&gt;server&lt;/span&gt; {
     &lt;span class=&quot;hljs-attribute&quot;&gt;listen&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;80&lt;/span&gt;;
     &lt;span class=&quot;hljs-attribute&quot;&gt;listen&lt;/span&gt; [::]:&lt;span class=&quot;hljs-number&quot;&gt;80&lt;/span&gt;;

     &lt;span class=&quot;hljs-attribute&quot;&gt;server_name&lt;/span&gt; my_domain.org; 

     &lt;span class=&quot;hljs-section&quot;&gt;location&lt;/span&gt; /.well-known/acme-challenge/ {
             &lt;span class=&quot;hljs-attribute&quot;&gt;allow&lt;/span&gt; all;
             &lt;span class=&quot;hljs-attribute&quot;&gt;root&lt;/span&gt; /var/www/certbot;
     }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;file and include &lt;code&gt;server_name&lt;/code&gt; followed by your domain.&lt;/p&gt;
&lt;h5&gt;3) mount/nginx.conf&lt;/h5&gt;
&lt;pre&gt;&lt;code class=&quot;language-nginx&quot;&gt;&lt;span class=&quot;hljs-attribute&quot;&gt;user&lt;/span&gt; nginx;
&lt;span class=&quot;hljs-attribute&quot;&gt;worker_processes&lt;/span&gt; auto;
&lt;span class=&quot;hljs-attribute&quot;&gt;worker_priority&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;;

&lt;span class=&quot;hljs-attribute&quot;&gt;pid&lt;/span&gt; /run/nginx.pid;
&lt;span class=&quot;hljs-attribute&quot;&gt;include&lt;/span&gt; /etc/nginx/modules-enabled/&lt;span class=&quot;hljs-regexp&quot;&gt;*.conf&lt;/span&gt;;

&lt;span class=&quot;hljs-section&quot;&gt;events&lt;/span&gt; {
        &lt;span class=&quot;hljs-attribute&quot;&gt;worker_connections&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;1024&lt;/span&gt;;
        &lt;span class=&quot;hljs-attribute&quot;&gt;multi_accept&lt;/span&gt; &lt;span class=&quot;hljs-literal&quot;&gt;off&lt;/span&gt;;
}

&lt;span class=&quot;hljs-section&quot;&gt;http&lt;/span&gt; {

        &lt;span class=&quot;hljs-attribute&quot;&gt;sendfile&lt;/span&gt; &lt;span class=&quot;hljs-literal&quot;&gt;on&lt;/span&gt;;
        &lt;span class=&quot;hljs-attribute&quot;&gt;tcp_nopush&lt;/span&gt; &lt;span class=&quot;hljs-literal&quot;&gt;on&lt;/span&gt;;
        &lt;span class=&quot;hljs-attribute&quot;&gt;tcp_nodelay&lt;/span&gt; &lt;span class=&quot;hljs-literal&quot;&gt;on&lt;/span&gt;;
        &lt;span class=&quot;hljs-attribute&quot;&gt;keepalive_timeout&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;65&lt;/span&gt;;
        &lt;span class=&quot;hljs-attribute&quot;&gt;types_hash_max_size&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;2048&lt;/span&gt;;
        &lt;span class=&quot;hljs-attribute&quot;&gt;server_tokens&lt;/span&gt; &lt;span class=&quot;hljs-literal&quot;&gt;off&lt;/span&gt;;

        &lt;span class=&quot;hljs-attribute&quot;&gt;include&lt;/span&gt; /etc/nginx/mime.types;
        &lt;span class=&quot;hljs-attribute&quot;&gt;default_type&lt;/span&gt; application/octet-stream;
        &lt;span class=&quot;hljs-attribute&quot;&gt;log_format&lt;/span&gt;  main  &lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;&lt;span class=&quot;hljs-variable&quot;&gt;$remote_addr&lt;/span&gt; - &lt;span class=&quot;hljs-variable&quot;&gt;$remote_user&lt;/span&gt; [&lt;span class=&quot;hljs-variable&quot;&gt;$time_local&lt;/span&gt;] &amp;quot;&lt;span class=&quot;hljs-variable&quot;&gt;$request&lt;/span&gt;&amp;quot; &amp;#x27;&lt;/span&gt;
                          &lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;&lt;span class=&quot;hljs-variable&quot;&gt;$status&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;$body_bytes_sent&lt;/span&gt; &amp;quot;&lt;span class=&quot;hljs-variable&quot;&gt;$http_referer&lt;/span&gt;&amp;quot; &amp;#x27;&lt;/span&gt;
                          &lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;&amp;quot;&lt;span class=&quot;hljs-variable&quot;&gt;$http_user_agent&lt;/span&gt;&amp;quot; &amp;quot;&lt;span class=&quot;hljs-variable&quot;&gt;$http_x_forwarded_for&lt;/span&gt;&amp;quot;&amp;#x27;&lt;/span&gt;;

        &lt;span class=&quot;hljs-attribute&quot;&gt;ssl_protocols&lt;/span&gt; TLSv1 TLSv1.&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt; TLSv1.&lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt; TLSv1.&lt;span class=&quot;hljs-number&quot;&gt;3&lt;/span&gt;; &lt;span class=&quot;hljs-comment&quot;&gt;# Dropping SSLv3, ref: POODLE&lt;/span&gt;
        &lt;span class=&quot;hljs-attribute&quot;&gt;ssl_prefer_server_ciphers&lt;/span&gt; &lt;span class=&quot;hljs-literal&quot;&gt;on&lt;/span&gt;;

        &lt;span class=&quot;hljs-attribute&quot;&gt;access_log&lt;/span&gt; /var/log/nginx/access.log main;
        &lt;span class=&quot;hljs-attribute&quot;&gt;error_log&lt;/span&gt; /var/log/nginx/&lt;span class=&quot;hljs-literal&quot;&gt;error&lt;/span&gt;.log &lt;span class=&quot;hljs-literal&quot;&gt;debug&lt;/span&gt;;

        &lt;span class=&quot;hljs-attribute&quot;&gt;gzip&lt;/span&gt; &lt;span class=&quot;hljs-literal&quot;&gt;on&lt;/span&gt;;

        &lt;span class=&quot;hljs-attribute&quot;&gt;include&lt;/span&gt; /etc/nginx/sites-available/*;

}

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is a pretty basic setup based on what you&apos;ll find when you first install nginx.&lt;/p&gt;
&lt;h5&gt;4) Issue a validated certificate through Let&apos;s Encrypt&lt;/h5&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;curl -L https://raw.githubusercontent.com/wmnnd/nginx-certbot/master/init-letsencrypt.sh -o init-letsencrypt.sh
&lt;span class=&quot;hljs-built_in&quot;&gt;chmod&lt;/span&gt; +x init-letsencrypt.sh
vi init-letsencrypt.sh			&lt;span class=&quot;hljs-comment&quot;&gt;# 여기서 도메인과 메일 주소를 입력해야 함&lt;/span&gt;
&lt;span class=&quot;hljs-built_in&quot;&gt;sudo&lt;/span&gt; ./init-letsencrypt.sh
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Get the file that will help you with the certificate issuance process externally and set the permissions. You can then enter your domain and email address into the file and run the file to issue the certificate. If the issuance fails, you can view the logs to find out why it failed, fix it, and try again.&lt;/p&gt;
&lt;h4&gt;7. Setting up Nginx for certificate renewal&lt;/h4&gt;
&lt;pre&gt;&lt;code class=&quot;language-yml&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;# Nginx 설정&lt;/span&gt;
  &lt;span class=&quot;hljs-attr&quot;&gt;nginx:&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;container_name:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;nginx&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;image:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;nginx:latest&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;restart:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;unless-stopped&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;volumes:&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;./mount/nginx.conf:/etc/nginx/nginx.conf&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;./mount/sites-available:/etc/nginx/sites-available&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;./data/certbot/conf:/etc/letsencrypt&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;./data/certbot/www:/var/www/certbot&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;ports:&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;80&lt;/span&gt;&lt;span class=&quot;hljs-string&quot;&gt;:80&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;443&lt;/span&gt;&lt;span class=&quot;hljs-string&quot;&gt;:443&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;environment:&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;TZ=Asia/Seoul&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;networks:&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; {&lt;span class=&quot;hljs-string&quot;&gt;연결을&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;원하는&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;네트워크&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;이름&lt;/span&gt;}
    &lt;span class=&quot;hljs-attr&quot;&gt;command:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;/bin/sh -c &amp;#x27;while :; do sleep 6h &amp;amp; wait $${!}; nginx -s reload; done &amp;amp; nginx -g \&amp;quot;daemon off;\&amp;quot;&amp;#x27;&amp;quot;&lt;/span&gt;

  &lt;span class=&quot;hljs-comment&quot;&gt;# Certbot 컨테이너 설정&lt;/span&gt;
  &lt;span class=&quot;hljs-attr&quot;&gt;certbot:&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;container_name:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;certbot&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;image:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;certbot/certbot&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;restart:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;unless-stopped&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;volumes:&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;./data/certbot/conf:/etc/letsencrypt&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;./data/certbot/www:/var/www/certbot&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;environment:&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;TZ=Asia/Seoul&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;entrypoint:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;/bin/sh -c &amp;#x27;trap exit TERM; while :; do certbot renew; sleep 12h &amp;amp; wait $${!}; done;&amp;#x27;&amp;quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Certificates issued by Let&apos;s Encrypt have a limited lifespan, but you can reissue them if they are nearing expiration. You can add reissue-related commands to the certbot and nginx containers to handle certificate renewals automatically. This will prevent nginx from failing to build the container with an error because the certificate has been issued.&lt;/p&gt;
&lt;h4&gt;8. Install Docker inside the Jenkins container&lt;/h4&gt;
&lt;hr&gt;
&lt;blockquote&gt;
&lt;p&gt;Added) I originally listed the commands directly, but realized it wasn&apos;t intuitive, so I fixed it!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;# /jenkins-docker-install.sh&lt;/span&gt;

apt-get update
apt-get install ca-certificates curl gnupg

install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
&lt;span class=&quot;hljs-built_in&quot;&gt;chmod&lt;/span&gt; a+r /etc/apt/keyrings/docker.gpg

&lt;span class=&quot;hljs-built_in&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;deb [arch=&lt;span class=&quot;hljs-subst&quot;&gt;$(dpkg --print-architecture)&lt;/span&gt; signed-by=/etc/apt/keyrings/docker.gpg] \
https://download.docker.com/linux/debian \
&lt;span class=&quot;hljs-subst&quot;&gt;$(. /etc/os-release &amp;amp;&amp;amp; echo &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;&lt;span class=&quot;hljs-variable&quot;&gt;$VERSION_CODENAME&lt;/span&gt;&amp;quot;&lt;/span&gt;)&lt;/span&gt; stable&amp;quot;&lt;/span&gt; | \
&lt;span class=&quot;hljs-built_in&quot;&gt;tee&lt;/span&gt; /etc/apt/sources.list.d/docker.list &amp;gt; /dev/null

apt-get update
apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I created a sh file with the code to remove the sudo command from the existing docker installation method. You can put this file inside via mount and run it for a clean, one-room installation!&lt;/p&gt;
&lt;hr&gt;
&lt;h4&gt;9. Processing Docker Compose&lt;/h4&gt;
&lt;pre&gt;&lt;code class=&quot;language-yaml&quot;&gt;&lt;span class=&quot;hljs-attr&quot;&gt;version:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;3.8&amp;#x27;&lt;/span&gt;

&lt;span class=&quot;hljs-attr&quot;&gt;networks:&lt;/span&gt;
  {&lt;span class=&quot;hljs-string&quot;&gt;네트워크&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;이름&lt;/span&gt;}&lt;span class=&quot;hljs-string&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;driver:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;bridge&lt;/span&gt;

&lt;span class=&quot;hljs-attr&quot;&gt;services:&lt;/span&gt;

  &lt;span class=&quot;hljs-comment&quot;&gt;# Jenkins Container 설정&lt;/span&gt;
  &lt;span class=&quot;hljs-attr&quot;&gt;jenkins:&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;container_name:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;jenkins&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;image:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;jenkins/jenkins:lts&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;restart:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;unless-stopped&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;ports:&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;{포트 번호}:8080&amp;quot;&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;volumes:&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;./mount/jenkins:/var/jenkins_home&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;/var/run/docker.sock:/var/run/docker.sock&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;./mount/jenkins-html:/var/lib/jenkins&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;./jenkins-docker-install.sh:/jenkins-docker-install.sh&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;user:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;root&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;environment:&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;TZ=Asia/Seoul&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;networks:&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; {&lt;span class=&quot;hljs-string&quot;&gt;네트워크&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;이름&lt;/span&gt;}

&lt;span class=&quot;hljs-comment&quot;&gt;# Nginx 설정&lt;/span&gt;
  &lt;span class=&quot;hljs-attr&quot;&gt;nginx:&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;container_name:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;nginx&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;image:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;nginx:latest&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;restart:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;unless-stopped&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;volumes:&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;./mount/nginx/nginx.conf:/etc/nginx/nginx.conf&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;./mount/nginx/sites-available:/etc/nginx/sites-available&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;./data/certbot/conf:/etc/letsencrypt&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;./data/certbot/www:/var/www/certbot&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;ports:&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;80&lt;/span&gt;&lt;span class=&quot;hljs-string&quot;&gt;:80&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;443&lt;/span&gt;&lt;span class=&quot;hljs-string&quot;&gt;:443&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;environment:&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;TZ=Asia/Seoul&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;networks:&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; {&lt;span class=&quot;hljs-string&quot;&gt;네트워크&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;이름&lt;/span&gt;}
    &lt;span class=&quot;hljs-attr&quot;&gt;depends_on:&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; {&lt;span class=&quot;hljs-string&quot;&gt;선행&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;컨테이너&lt;/span&gt;}
    &lt;span class=&quot;hljs-attr&quot;&gt;command:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;/bin/sh -c &amp;#x27;while :; do sleep 6h &amp;amp; wait $${!}; nginx -s reload; done &amp;amp; nginx -g \&amp;quot;daemon off;\&amp;quot;&amp;#x27;&amp;quot;&lt;/span&gt;

  &lt;span class=&quot;hljs-comment&quot;&gt;# Certbot 컨테이너 설정&lt;/span&gt;
  &lt;span class=&quot;hljs-attr&quot;&gt;certbot:&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;container_name:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;certbot&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;image:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;certbot/certbot&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;restart:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;unless-stopped&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;volumes:&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;./data/certbot/conf:/etc/letsencrypt&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;./data/certbot/www:/var/www/certbot&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;environment:&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;TZ=Asia/Seoul&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;entrypoint:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;/bin/sh -c &amp;#x27;trap exit TERM; while :; do certbot renew; sleep 12h &amp;amp; wait $${!}; done;&amp;#x27;&amp;quot;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After adding these Jenkins configurations, run&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&lt;span class=&quot;language-xml&quot;&gt;docker-compose -f &lt;/span&gt;&lt;span class=&quot;hljs-template-variable&quot;&gt;{yml 파일 위치 및 파일명}&lt;/span&gt;&lt;span class=&quot;language-xml&quot;&gt; up -d
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;command to bring up all the containers.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;docker &lt;span class=&quot;hljs-built_in&quot;&gt;exec&lt;/span&gt; -it jenkins bin/bash
sh /jenkins-docker-install.sh
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;By installing Docker inside the Jenkins container, we can control the Docker Engine through the Jenkins internal Shell commands.
We&apos;ll follow the existing Docker documentation, but the difference is that we won&apos;t be using sudo and we&apos;ll be installing Docker for Debian.&lt;/p&gt;
&lt;h3&gt;Optional&lt;/h3&gt;
&lt;h4&gt;1. Set up Swap Memory&lt;/h4&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;# swap memory 설정&lt;/span&gt;

&lt;span class=&quot;hljs-built_in&quot;&gt;sudo&lt;/span&gt; fallocate -l {설정 용량} /swapfile   &lt;span class=&quot;hljs-comment&quot;&gt;# 설정 용량은 대체로 G 단위로 설정한다.&lt;/span&gt;
&lt;span class=&quot;hljs-built_in&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;chmod&lt;/span&gt; 600 /swapfile
&lt;span class=&quot;hljs-built_in&quot;&gt;sudo&lt;/span&gt; mkswap /swapfile
&lt;span class=&quot;hljs-built_in&quot;&gt;sudo&lt;/span&gt; swapon /swapfile

&lt;span class=&quot;hljs-comment&quot;&gt;# 재부팅 시에도 지속 사용을 원할 경우&lt;/span&gt;

&lt;span class=&quot;hljs-built_in&quot;&gt;sudo&lt;/span&gt; vi /etc/fstab 			&lt;span class=&quot;hljs-comment&quot;&gt;# &amp;#x27;/swapfile swap swap defaults 0 0&amp;#x27; 내용을 해당 파일에 삽입&lt;/span&gt;

&lt;span class=&quot;hljs-comment&quot;&gt;# swap 비활성화&lt;/span&gt;

&lt;span class=&quot;hljs-built_in&quot;&gt;sudo&lt;/span&gt; vi /etc/fstab 			&lt;span class=&quot;hljs-comment&quot;&gt;# &amp;#x27;/swapfile swap swap defaults 0 0&amp;#x27; 내용을 제거&lt;/span&gt;
&lt;span class=&quot;hljs-built_in&quot;&gt;sudo&lt;/span&gt; swapoff -v /swapfile
&lt;span class=&quot;hljs-built_in&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;rm&lt;/span&gt; /swapfile
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Depending on your instance performance and needs, you can set up swap memory to prevent instances from popping.&lt;/p&gt;
&lt;h4&gt;2. What to try if you get a Jenkins plugin installation error&lt;/h4&gt;
&lt;p&gt;&amp;lt;Solution 1
Access Jenkins Administration &amp;gt; Plugin Manager &amp;gt; Advanced settings &amp;gt; Update sites part
Change &lt;code&gt;https://updates.jenkins.io/update-center.json&lt;/code&gt; to &lt;code&gt;http://updates.jenkins.io/update-center.json&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;Solution 2&amp;gt;
Install the plugin named &lt;code&gt;skip-certificate-check&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;This is not a perfect solution, but we have seen some success with all of these solutions.&lt;/p&gt;
&lt;h3&gt;Closing remarks&lt;/h3&gt;
&lt;p&gt;I&apos;m going to stop writing about Docker here, except for some framework deployments later on. I&apos;ll write more about deployments in the future if I get the chance, as it&apos;s a great feeling to see your work on a real network.&lt;/p&gt;
</content:encoded></item><item><title>[Interview Question] What is a RESTful API?</title><link>https://www.traceoflight.dev/en/blog/restful-api/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/restful-api/</guid><description>Organize interview questions about RESTful APIs</description><pubDate>Sun, 21 May 2023 17:27:57 GMT</pubDate><content:encoded>&lt;h3&gt;RESTful API&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Refers to a RESTful API.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-3a8f738579ac35de-image.jpg&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;It&apos;s pretty self-explanatory, but it is what it sounds like!
So let&apos;s take a look at what each word means, and you&apos;ll see what a RESTful API is all about.&lt;/p&gt;
&lt;h3&gt;API&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Short for Application Programming Interface.
A mechanism that allows two software components to communicate with each other using a set of definitions and protocols.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This is how I define it. The way I understand it is that different components of software have different ways of dealing with objects and so on, and to deal with this disparity, a convention is established so that they can communicate and interact with each other.&lt;/p&gt;
&lt;h3&gt;REST&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Representational State Transfer.
One of the software architectures for distributed hypermedia systems such as the World Wide Web.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;REST was initially created as a guideline for managing communication in complex networks such as the Internet, and is said to be reliable for large-scale communication and easy to implement and modify.&lt;/p&gt;
&lt;h4&gt;Principles of REST Architecture&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Uniform Interface&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Server sends information in a standardized format&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The standard format may differ from the internal representation of the resource on the server&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;All API requests for the same resource are the same regardless of the specific language, platform, etc.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Stateless&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Each request is independent of all other requests&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Server can fully understand and fulfill the request without additional information&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Layered System&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Multiple applications working together to fulfill client requests&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Multiple tiers of servers, where different authorized intermediaries may exist between the server and the client&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Additional intermediaries such as proxies and gateways, encryption, load-balancing layers, etc.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Remains invisible to the client&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Cacheable (Cacheable)&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Supports caching to store some responses to improve server response times&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Implements caching on the client or server side&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;On Demand Code (On Demand Code)&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Deliver resources that are typically static&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Includes executable code in responses on demand, allowing you to temporarily extend or customize client functionality&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Benefits of using RESTful APIs&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Scalability&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Scalable because it optimizes client-server interactions&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Flexibility&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Supports full client-server separation&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Simplify &amp;amp; separate server components so each part can evolve independently&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Independence&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Independent of the technology used&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Ability to write client &amp;amp; server applications using different programming languages and change technologies, regardless of API design&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;What is RESTful API?
It refers to an application programming interface using REST architecture, which is a convention that organizes the interaction between programs that adhere to the principles of REST architecture.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;So what are the benefits?
The benefits of using these APIs are scalability, flexibility, and independence!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;See also.&lt;/h3&gt;
&lt;p&gt;[[AWS] What are RESTful APIs?&amp;quot;(&lt;a href=&quot;https://aws.amazon.com/ko/what-is/restful-api/&quot;&gt;https://aws.amazon.com/ko/what-is/restful-api/&lt;/a&gt;)&lt;/p&gt;
</content:encoded></item><item><title>[1Day-1CS] Coverage of network devices</title><link>https://www.traceoflight.dev/en/blog/1day-1cs-2e8effb4/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/1day-1cs-2e8effb4/</guid><description>1 Day 1CS, a quick refresher on the coverage of network devices and which ones handle the application layer</description><pubDate>Fri, 19 May 2023 17:06:42 GMT</pubDate><content:encoded>&lt;blockquote&gt;
&lt;p&gt;2023-06-18 Edit Content Scope&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Hierarchical processing scope&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Application layer: L7 switches&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Internet layer: L3 switches, routers&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Data link layer: L2 switches, bridges&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Physical layer: NICs, repeaters, APs&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
</content:encoded></item><item><title>Start organizing your interview questions! (Question history)</title><link>https://www.traceoflight.dev/en/blog/velog-bdb80888/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/velog-bdb80888/</guid><description>Organizing practice interview questions and why you should start</description><pubDate>Tue, 16 May 2023 22:32:46 GMT</pubDate><content:encoded>&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-2d4a54a2ae94fc97-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h3&gt;Instrument&lt;/h3&gt;
&lt;p&gt;I don&apos;t know how long it&apos;s been since I started putting my resume in front of companies in earnest... I think it&apos;s been about 3 months, but I&apos;m not passing all the coding tests, but I&apos;m passing quite a few of them, and I&apos;ve had a few interviews recently!&lt;/p&gt;
&lt;p&gt;But even if I go to an interview, even if I have studied CS, there is a difference between the questions that come up in the interview and the CS knowledge I have studied... So I would like to blog about the questions that came up in the interview and what I studied with Pinpoint.&lt;/p&gt;
&lt;h3&gt;List of questions&lt;/h3&gt;
&lt;h4&gt;Overall&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;/blog/restful-api&quot;&gt;What is RESTful API?&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;/blog/process-thread&quot;&gt;The difference between Process and Thread&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;/blog/fork-exec&quot;&gt;Difference between Fork and Exec&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;/blog/framework-library&quot;&gt;Framework vs. Library&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;What is a Transaction?&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;About OSI Layer 7&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Subnets, Gateways, and Private IPs&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Backend&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;/blog/db-index&quot;&gt;What is DB Index?&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;/blog/connection-pool&quot;&gt;What is Connection Pool?&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;/blog/jvm&quot;&gt;JVM의 구조와 원리&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;/blog/java-stack-heap&quot;&gt;Java Heap &amp;amp; Stack의 구조&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;/blog/dependency-injection&quot;&gt;Dependency Injection&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;How Spring IoC containers manage beans.
+ Proxy pattern, how Spring Beans are proxies and how to achieve multithreaded behavior.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Singleton pattern and Spring Dependency Injection&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Frontend&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;What happens when you type the access URL in the address bar&lt;/li&gt;
&lt;/ul&gt;
</content:encoded></item><item><title>[1Day-1CS] Cross-Tier Data Sending and Receiving Courses &amp; PDUs</title><link>https://www.traceoflight.dev/en/blog/1day-1cs-pdu/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/1day-1cs-pdu/</guid><description>A quick refresher on 1CS, cross-layer data transmission and TDUs</description><pubDate>Sun, 07 May 2023 17:02:23 GMT</pubDate><content:encoded>&lt;h3&gt;Encapsulation &amp;amp; decapsulation process&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Encapsulation: embedding the header and data of a higher layer into the data portion of a lower layer and inserting the header of that layer.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Application → Transport → Internet → Pass to link layer&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Passed to transport layer, where it is segmented or datagrammed + TCP (Layer 4) headers added&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Passes to the Internet layer, where an IP (Layer 3) header is added = packet&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Passes to the link layer and adds a frame header + frame trailer = frame&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;Decapsulation: the process of removing the header portion of each layer as it goes from lower to higher layers&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Decapsulation proceeds in reverse&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Frame → Packet → Segment, Datagram → Message&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Eventually delivered as Transmission Data Unit (TDU) messages in the application&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Protocol Data Unit&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;A unit of chunk when data is passed from layer to layer&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Different layers have different names, such as message, segment, datagram, packet, frame, bit, etc.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Transmitting in bits is fastest and most efficient&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;String-based sending and receiving at the application layer (due to ease of scaling)&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
</content:encoded></item><item><title>[1Day-1CS] Half-duplex communication (2), wireless communication and Ethernet frames</title><link>https://www.traceoflight.dev/en/blog/1day-1cs-70a48fb3/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/1day-1cs-70a48fb3/</guid><description>1 Day A quick refresher on 1CS, half-duplex communications, wireless communications, and Ethernet frames</description><pubDate>Thu, 04 May 2023 14:01:28 GMT</pubDate><content:encoded>&lt;h3&gt;Types of half-duplex communication&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;CSMA/CD: Sends data and retransmits after a period of time if a collision occurs.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;CSMA/CA: Avoids collisions as much as possible by proactively detecting carriers before sending data, etc.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Checking the wireless medium before sending data&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Determining if the line is empty (carrier detection)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If busy, checks for availability at increasing intervals based on random values (IFS)&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Wireless Communications&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Wifi: Technology that allows electronic devices to connect to a wireless LAN signal; requires a wireless access device.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;BSS (Basic Service Set)&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Standing for Basic Service Set&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Simple access through a router + APs and devices within the same BSS can communicate with each other&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Extended Service Set (ESS)&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;One or more connected BSS groups&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Provides long-range wireless communication&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Enables more availability and mobility than BSS&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Allows you to move from one location to another and stay connected to the network without interruption&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Ethernet frames&lt;/h3&gt;
&lt;p&gt;A transport mechanism used at the data link layer&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Preamble: announces the start of an Ethernet frame&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;SFD (Start Frame Delimiter): Signals that the MAC address field begins with the next byte.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;DMAC, SMAC: Transmit and receive MAC addresses&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;EtherType: defines the IP protocol&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Payload: Data received&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;CRC: Error checking bits&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
</content:encoded></item><item><title>[BOJ 2473, Python] Tax Solutions</title><link>https://www.traceoflight.dev/en/blog/boj2473/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/boj2473/</guid><description>Python Solution to BOJ 2473, &quot;Three Solutions&quot; Problem</description><pubDate>Thu, 04 May 2023 13:15:05 GMT</pubDate><content:encoded>&lt;h3&gt;Problem link&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;@@tlp1@@&quot;&gt;boj 2473&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Classification&lt;/h3&gt;
&lt;p&gt;Bisection, sorting, two pointers&lt;/p&gt;
&lt;h3&gt;Description&lt;/h3&gt;
&lt;p&gt;This is a slightly more advanced version of the classic two-pointer problem.&lt;/p&gt;
&lt;p&gt;When I first solved this problem, I thought there must be a different solution because I had to combine the three solutions, so I surprisingly didn&apos;t use the exact method, which slowed down the actual solution.&lt;/p&gt;
&lt;p&gt;The important thing to note about this problem is that the total number of solutions is 5000 or less. Without this condition, this problem would never be solved in time... I&apos;m glad I didn&apos;t pay attention to this condition in the beginning, as it led me to keep looking for other solutions.&lt;/p&gt;
&lt;p&gt;So, the solution to this problem is as follows.&lt;/p&gt;
&lt;p&gt;Sort the order → fix one solution → use a two-pointer algorithm for the remaining solutions to sum with that solution to get closest to zero → stop when all have been traversed or when zero is reached&lt;/p&gt;
&lt;h3&gt;Solving code&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;# 세 용액&lt;/span&gt;

&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; sys

&lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt; = sys.stdin.readline

solution_number = &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt;())
solution_list = &lt;span class=&quot;hljs-built_in&quot;&gt;list&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;map&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;, &lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt;().split()))

solution_list.sort()
characteristic_value = &lt;span class=&quot;hljs-number&quot;&gt;3000000000&lt;/span&gt;

&lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; idx &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(solution_number):

    pointer_1 = &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;
    pointer_2 = solution_number - &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;

    &lt;span class=&quot;hljs-keyword&quot;&gt;while&lt;/span&gt; pointer_1 &amp;lt; pointer_2:

        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; pointer_1 == idx:
            pointer_1 += &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; pointer_2 == idx:
            pointer_2 -= &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;

        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; pointer_1 &amp;gt;= pointer_2:
            &lt;span class=&quot;hljs-keyword&quot;&gt;break&lt;/span&gt;

        now_value = &lt;span class=&quot;hljs-built_in&quot;&gt;sum&lt;/span&gt;([solution_list[idx], solution_list[pointer_1], solution_list[pointer_2]])

        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;abs&lt;/span&gt;(now_value) &amp;lt; characteristic_value:
            characteristic_value = &lt;span class=&quot;hljs-built_in&quot;&gt;abs&lt;/span&gt;(now_value)
            result = [solution_list[idx], solution_list[pointer_1], solution_list[pointer_2]]

            &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;not&lt;/span&gt; characteristic_value:
                &lt;span class=&quot;hljs-keyword&quot;&gt;break&lt;/span&gt;

        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; now_value &amp;lt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;:
            pointer_1 += &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;elif&lt;/span&gt; now_value &amp;gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;:
            pointer_2 -= &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;

    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;not&lt;/span&gt; characteristic_value:
        &lt;span class=&quot;hljs-keyword&quot;&gt;break&lt;/span&gt;

result.sort()

&lt;span class=&quot;hljs-built_in&quot;&gt;print&lt;/span&gt;(*result)

&lt;/code&gt;&lt;/pre&gt;
</content:encoded></item><item><title>[1Day-1CS] Full and half duplex communication (1)</title><link>https://www.traceoflight.dev/en/blog/1day-1cs-1/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/1day-1cs-1/</guid><description>1 Day 1CS, A Quick Recap of the Introduction to Full and Half Duplex Communications</description><pubDate>Mon, 01 May 2023 16:24:13 GMT</pubDate><content:encoded>&lt;h3&gt;Full-duplex communication&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;A method in which both devices can transmit and receive simultaneously.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Separate transmit and receive paths to send and receive data&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Modern Fast Ethernet uses this method&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Half-duplex communication&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Both devices can communicate with each other, but not at the same time
Only one direction of communication at a time based on one path&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;If there is a collision after sending data, proceed with retransmission after a period of time&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Wired LAN&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Twisted pair cable: cable twisted together to reduce noise (crosstalk)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Fiber optic cable: A cable that transmits light by utilizing the difference in refractive index of the core and cable.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Wireless LAN&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Half-duplex communication, which uses the same channel for both transmitting and receiving.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
</content:encoded></item><item><title>[1Day-1CS] Internet Layer and Link Layer</title><link>https://www.traceoflight.dev/en/blog/1day-1cs-e167b4e7/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/1day-1cs-e167b4e7/</guid><description>1 Day 1CS, A Quick Recap of the Internet Layer and Link Layer</description><pubDate>Thu, 27 Apr 2023 03:32:49 GMT</pubDate><content:encoded>&lt;h3&gt;Internet Layer&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Layer used to transmit network packets received from a device to the destination specified by its IP address.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Link layer&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;The layer that actually passes data and sets the rules for signaling back and forth between devices, also known as the network access layer.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Physical layer: The layer that sends data consisting of 0s and 1s over the LAN.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Data link layer: The layer responsible for error checking, flow and access control over Ethernet frames.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
</content:encoded></item><item><title>[1Day-1CS] Transport Layer</title><link>https://www.traceoflight.dev/en/blog/1day-1cs-f7e9e56d/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/1day-1cs-f7e9e56d/</guid><description>1CS in 1 day, a quick refresher on the transport layer</description><pubDate>Tue, 25 Apr 2023 17:14:48 GMT</pubDate><content:encoded>&lt;h3&gt;Transport Layer&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Provides communication services that connect senders and receivers.
Provides connection-oriented data stream support, reliability, and flow control
Serves as a data delivery intermediary between the application and Internet layers&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;TCP: Guarantees order, uses connection-oriented protocol, acknowledges receipt (virtual line packet exchange)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;UDP: ordering X, acknowledgments X, simple data delivery (datagram packet exchange)&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Virtual line packet exchange method&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Each packet contains a virtual line identifier&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Virtual line is released when all packets have been sent, packets arrive in order of transmission&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;How datagram packets are exchanged&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Packets travel independently, choose the best path&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Can be sent on different paths and in different order&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;How TCP establishes and tears down connections&lt;/h3&gt;
&lt;h4&gt;connection: 3-way handshake&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;client sends connection request flag with its ISN&lt;/li&gt;
&lt;li&gt;server sends back server&apos;s ISN and client&apos;s ISN + 1 with authorization number&lt;/li&gt;
&lt;li&gt;client replies back with server&apos;s ISN + 1 with authorization number&lt;/li&gt;
&lt;/ol&gt;
&lt;h4&gt;Disconnecting: 4-way handshake&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;client sends FIN set segment and enters FIN_WAIT&lt;/li&gt;
&lt;li&gt;the server that received the data sends an ACK acknowledgment segment to the client and enters CLOSE_WAIT&lt;/li&gt;
&lt;li&gt;sends FIN segment after some time has passed since ACK was sent&lt;/li&gt;
&lt;li&gt;client receives ACK, enters TIME_WAIT and resends ACK back to server&lt;/li&gt;
&lt;li&gt;the receiving server sends a CLOSE&lt;/li&gt;
&lt;/ol&gt;
&lt;blockquote&gt;
&lt;p&gt;Reasons for using TIME_WAIT: Possibility of delayed packets, confirmation of disconnection&lt;/p&gt;
&lt;/blockquote&gt;
</content:encoded></item><item><title>[BOJ 7490, Python] Create 0</title><link>https://www.traceoflight.dev/en/blog/boj7490/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/boj7490/</guid><description>Python Solution to BOJ 7490, &quot;Make Zero&quot; Problem</description><pubDate>Mon, 24 Apr 2023 16:15:36 GMT</pubDate><content:encoded>&lt;h3&gt;Problem link&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;@@tlp1@@&quot;&gt;boj 7490&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Classification&lt;/h3&gt;
&lt;p&gt;Backtracking, Brute Force Algorithms, Implementations, Strings&lt;/p&gt;
&lt;h3&gt;Description&lt;/h3&gt;
&lt;p&gt;I think this is a classic backtracking problem. However, I found the processing a bit esoteric and the ASCII sorting a bit unusual.&lt;/p&gt;
&lt;p&gt;I saw that it could be easily solved using Python&apos;s Eval function, but I didn&apos;t use that approach and solved it the hard way.&lt;/p&gt;
&lt;p&gt;Basically, I took the sum of a number and two previously unprocessed numbers and backtracked, thinking that it would check for all three cases of &apos;addition&apos;, &apos;subtraction&apos;, and &apos;no operation&apos;, and I was able to get the correct answer.&lt;/p&gt;
&lt;h3&gt;Solved code.&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;# 0 만들기&lt;/span&gt;

&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; sys

&lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt; = sys.stdin.readline

&lt;span class=&quot;hljs-keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;make_sum_zero&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;
    result_arr: &lt;span class=&quot;hljs-built_in&quot;&gt;set&lt;/span&gt;,
    target_arr: &lt;span class=&quot;hljs-built_in&quot;&gt;list&lt;/span&gt;,
    last_index: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;,
    now_index: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt; = &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;,
    sum_now: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt; = &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;,
    now_calc: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt; = &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;,
    log=[],
&lt;/span&gt;) -&amp;gt; &lt;span class=&quot;hljs-literal&quot;&gt;None&lt;/span&gt;:
    &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;&amp;quot;&amp;quot;
    백트래킹을 활용하여 숫자들의 합이 0이 되도록 만드는 함수
    &amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; last_index == now_index:
        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;not&lt;/span&gt; sum_now + now_calc:
            result_arr.add(&lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;.join(log))

    &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;:
        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;not&lt;/span&gt; now_index:
            make_sum_zero(
                result_arr,
                target_arr,
                last_index,
                now_index + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;,
                &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;,
                target_arr[now_index],
                [&lt;span class=&quot;hljs-built_in&quot;&gt;str&lt;/span&gt;(target_arr[now_index])],
            )

        &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;:
            new_number = target_arr[now_index]

            make_sum_zero(
                result_arr,
                target_arr,
                last_index,
                now_index + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;,
                sum_now + now_calc,
                new_number,
                log + [&lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;+&amp;quot;&lt;/span&gt;, &lt;span class=&quot;hljs-built_in&quot;&gt;str&lt;/span&gt;(new_number)],
            )
            make_sum_zero(
                result_arr,
                target_arr,
                last_index,
                now_index + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;,
                sum_now + now_calc,
                -new_number,
                log + [&lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;-&amp;quot;&lt;/span&gt;, &lt;span class=&quot;hljs-built_in&quot;&gt;str&lt;/span&gt;(new_number)],
            )

            &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; now_calc &amp;lt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;:
                make_sum_zero(
                    result_arr,
                    target_arr,
                    last_index,
                    now_index + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;,
                    sum_now,
                    &lt;span class=&quot;hljs-number&quot;&gt;10&lt;/span&gt; * now_calc - new_number,
                    log + [&lt;span class=&quot;hljs-string&quot;&gt;&amp;quot; &amp;quot;&lt;/span&gt;, &lt;span class=&quot;hljs-built_in&quot;&gt;str&lt;/span&gt;(new_number)],
                )
            &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;:
                make_sum_zero(
                    result_arr,
                    target_arr,
                    last_index,
                    now_index + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;,
                    sum_now,
                    &lt;span class=&quot;hljs-number&quot;&gt;10&lt;/span&gt; * now_calc + new_number,
                    log + [&lt;span class=&quot;hljs-string&quot;&gt;&amp;quot; &amp;quot;&lt;/span&gt;, &lt;span class=&quot;hljs-built_in&quot;&gt;str&lt;/span&gt;(new_number)],
                )

testcase = &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt;())
output = []

&lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; _ &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(testcase):
    arr_length = &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt;())
    result = &lt;span class=&quot;hljs-built_in&quot;&gt;set&lt;/span&gt;()

    &lt;span class=&quot;hljs-comment&quot;&gt;# 함수를 통해 결과 확인&lt;/span&gt;
    target_arr = [i &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; i &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, arr_length + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;)]
    make_sum_zero(result, target_arr, arr_length)

    &lt;span class=&quot;hljs-comment&quot;&gt;# 혹여라도 겹치는 결과가 있다면 Set을 통해 배제, ASCII 순으로 정렬&lt;/span&gt;
    sort_result = &lt;span class=&quot;hljs-built_in&quot;&gt;sorted&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;list&lt;/span&gt;(result), key=&lt;span class=&quot;hljs-keyword&quot;&gt;lambda&lt;/span&gt; x: &lt;span class=&quot;hljs-built_in&quot;&gt;ascii&lt;/span&gt;(x))
    output.append(sort_result)

&lt;span class=&quot;hljs-comment&quot;&gt;# 문제 조건에 맞춰 출력&lt;/span&gt;
&lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; idx &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(testcase):
    &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; element_idx &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;len&lt;/span&gt;(output[idx])):
        &lt;span class=&quot;hljs-built_in&quot;&gt;print&lt;/span&gt;(output[idx][element_idx])

    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; idx != testcase - &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;:
        &lt;span class=&quot;hljs-built_in&quot;&gt;print&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;)
&lt;/code&gt;&lt;/pre&gt;
</content:encoded></item><item><title>[1Day-1CS] The TCP/IP 4-layer model and the application layer</title><link>https://www.traceoflight.dev/en/blog/1day-1cs-tcp-ip-4/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/1day-1cs-tcp-ip-4/</guid><description>A Quick Overview of the TCP/IP 4-Layer Model and the Application Layer: 1 CS a Day</description><pubDate>Mon, 24 Apr 2023 15:18:37 GMT</pubDate><content:encoded>&lt;h3&gt;Internet Protocol Suite (&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;) A set of protocols used by computers to exchange information over the Internet&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Explained using the TCP/IP 4-layer model or the OSI 7-layer model&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;TCP/IP 4-layer model&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Composed of four abstraction layers based on the scope of networking&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Application layer&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Transport layer&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Internet Layer&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Link Layer&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The OSI model is characterized by its further subdivision of the Application Layer and Link Layer&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Application Layer&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The protocol layer where applications such as FTP, HTTP, SSH, SMTP, and DNS are used&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;FTP: File transfer between devices&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;SSH: Secure Shell Protocol, an encrypted network protocol&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;HTTP: The protocol used to access websites via the World Wide Web&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;SMTP: An Internet standard communication protocol for email transmission&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;DNS: A server that maps domain names to IP addresses&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The layer that actually provides services to users&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
</content:encoded></item><item><title>[BOJ 25542, Python] Meeting Place</title><link>https://www.traceoflight.dev/en/blog/boj25542/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/boj25542/</guid><description>Python Solution for BOJ 25542, &amp;quot;Meeting Place&amp;quot;</description><pubDate>Sun, 23 Apr 2023 18:10:04 GMT</pubDate><content:encoded>&lt;h3&gt;Problem Link&lt;/h3&gt;
&lt;p&gt;[BOJ 25542](&lt;a href=&quot;https://www.acmicpc.net/problem/25542&quot;&gt;https://www.acmicpc.net/problem/25542&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;h3&gt;Categories&lt;/h3&gt;
&lt;p&gt;Brute Force Algorithm, Implementation, Strings&lt;/p&gt;
&lt;h3&gt;Description&lt;/h3&gt;
&lt;p&gt;When I first encountered this problem in a contest, I thought the idea itself wasn’t difficult. However, it turned out to be more labor-intensive to implement than I expected, and since I was struggling even with writing Python code seven months ago, I couldn’t solve it.&lt;/p&gt;
&lt;p&gt;I also tried to solve this problem three months ago, but I concluded that my initial idea required additional pruning, so I had to set the problem aside once again.&lt;/p&gt;
&lt;p&gt;Recently, I’ve had some free time and felt the urge to revisit problems I hadn’t been able to solve before, so I gave it another shot—and finally managed to solve it! However, I still have my doubts about why this is classified as a Silver-level problem...&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-90c53486a9b70423-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;At first, I tried to generate results using only the given strings, but this inevitably failed because counterexamples existed.&lt;/p&gt;
&lt;p&gt;The code I tried next included a bit more implementation, but since it still relied solely on the given strings, it couldn’t handle counterexamples using other strings. I’ve attached the code below.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; sys
&lt;span class=&quot;hljs-keyword&quot;&gt;from&lt;/span&gt; itertools &lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; product

&lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt; = sys.stdin.readline

&lt;span class=&quot;hljs-keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;is_similar&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;checker: &lt;span class=&quot;hljs-built_in&quot;&gt;str&lt;/span&gt;, target: &lt;span class=&quot;hljs-built_in&quot;&gt;str&lt;/span&gt;&lt;/span&gt;) -&amp;gt; &lt;span class=&quot;hljs-built_in&quot;&gt;bool&lt;/span&gt;:
	&lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;&amp;#x27;&amp;#x27;
    두 문자열이 비슷한지 확인하는 함수
    &amp;#x27;&amp;#x27;&amp;#x27;&lt;/span&gt;
    
    length = &lt;span class=&quot;hljs-built_in&quot;&gt;len&lt;/span&gt;(checker)
    counter = &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;

    &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; idx &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(length):

        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; checker[idx] != target[idx]:
            counter += &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;

    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; counter &amp;lt;= &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;:
        &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hljs-literal&quot;&gt;True&lt;/span&gt;
    
    &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;:
        &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hljs-literal&quot;&gt;False&lt;/span&gt;

&lt;span class=&quot;hljs-comment&quot;&gt;# 입력&lt;/span&gt;
store_number, name_length = &lt;span class=&quot;hljs-built_in&quot;&gt;map&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;, &lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt;().split())

&lt;span class=&quot;hljs-comment&quot;&gt;# 각 문자열의 동일 인덱스를 집합화&lt;/span&gt;
name_list = []
store_chr_arr = [&lt;span class=&quot;hljs-built_in&quot;&gt;set&lt;/span&gt;() &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; _ &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(name_length)]

&lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; _ &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(store_number):
    each_name = &lt;span class=&quot;hljs-built_in&quot;&gt;list&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt;())
    name_list.append(each_name)

    &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; idx &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(name_length):
        store_chr_arr[idx].add(each_name[idx])

result = &lt;span class=&quot;hljs-literal&quot;&gt;None&lt;/span&gt;

&lt;span class=&quot;hljs-comment&quot;&gt;# 겹치지 않는 문자열의 Product를 비교&lt;/span&gt;
&lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; each_name_combination &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; product(*store_chr_arr):
    target_name = &lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;&amp;#x27;&lt;/span&gt;.join(each_name_combination)
    
    is_answer = &lt;span class=&quot;hljs-literal&quot;&gt;True&lt;/span&gt;

    &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; check_name &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; name_list:
        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;not&lt;/span&gt; is_similar(target_name, check_name):
            is_answer = &lt;span class=&quot;hljs-literal&quot;&gt;False&lt;/span&gt;
            &lt;span class=&quot;hljs-keyword&quot;&gt;break&lt;/span&gt;

    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; is_answer:
        result = target_name
        &lt;span class=&quot;hljs-keyword&quot;&gt;break&lt;/span&gt;

&lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; result &lt;span class=&quot;hljs-keyword&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;hljs-literal&quot;&gt;None&lt;/span&gt;:
    &lt;span class=&quot;hljs-built_in&quot;&gt;print&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;CALL FRIEND&amp;#x27;&lt;/span&gt;)

&lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;:
    &lt;span class=&quot;hljs-built_in&quot;&gt;print&lt;/span&gt;(result)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I had tried using unused characters at first, but my implementation skills weren’t sufficient enough to actually put it into practice; however, I was able to get a “Correct” result using that method.&lt;/p&gt;
&lt;h3&gt;Solution Code&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;# 약속 장소&lt;/span&gt;

&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; sys

&lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt; = sys.stdin.readline

&lt;span class=&quot;hljs-keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;is_similar&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;checker: &lt;span class=&quot;hljs-built_in&quot;&gt;str&lt;/span&gt;, target: &lt;span class=&quot;hljs-built_in&quot;&gt;str&lt;/span&gt;&lt;/span&gt;) -&amp;gt; &lt;span class=&quot;hljs-built_in&quot;&gt;bool&lt;/span&gt;:
    &lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;&amp;#x27;&amp;#x27;
    두 문자열이 비슷한지 확인하는 함수
    &amp;#x27;&amp;#x27;&amp;#x27;&lt;/span&gt;

    length = &lt;span class=&quot;hljs-built_in&quot;&gt;len&lt;/span&gt;(checker)
    counter = &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;

    &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; idx &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(length):

        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; checker[idx] != target[idx]:
            counter += &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;

    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; counter &amp;lt;= &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;:
        &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hljs-literal&quot;&gt;True&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;:
        &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hljs-literal&quot;&gt;False&lt;/span&gt;

&lt;span class=&quot;hljs-comment&quot;&gt;# 정보 입력&lt;/span&gt;
store_number, name_length = &lt;span class=&quot;hljs-built_in&quot;&gt;map&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;, &lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt;().split())

name_list = []
first_checker = &lt;span class=&quot;hljs-literal&quot;&gt;True&lt;/span&gt;

&lt;span class=&quot;hljs-comment&quot;&gt;# 첫 문자열만 따로 분류하고 나머지는 이름 리스트에 기록&lt;/span&gt;
&lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; _ &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(store_number):
    each_name = &lt;span class=&quot;hljs-built_in&quot;&gt;list&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt;().rstrip(&lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;\n&amp;#x27;&lt;/span&gt;))

    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; first_checker:
        target_name = each_name
        first_checker = &lt;span class=&quot;hljs-literal&quot;&gt;False&lt;/span&gt;

    &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;:
        name_list.append(each_name)

&lt;span class=&quot;hljs-comment&quot;&gt;# 첫 문자열을 통해 문자열 변형된 후보를 양산&lt;/span&gt;
result_set = &lt;span class=&quot;hljs-built_in&quot;&gt;set&lt;/span&gt;()

&lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; idx &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(name_length):
    &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; alpha &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(&lt;span class=&quot;hljs-number&quot;&gt;65&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;91&lt;/span&gt;):
        temp = target_name[:]
        temp[idx] = &lt;span class=&quot;hljs-built_in&quot;&gt;chr&lt;/span&gt;(alpha)
        result_set.add(&lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;&amp;#x27;&lt;/span&gt;.join(temp))

&lt;span class=&quot;hljs-comment&quot;&gt;# 확인하면서 후보를 소거&lt;/span&gt;
&lt;span class=&quot;hljs-keyword&quot;&gt;while&lt;/span&gt; result_set &lt;span class=&quot;hljs-keyword&quot;&gt;and&lt;/span&gt; name_list:

    now_check_name = name_list.pop()
    remove_target = &lt;span class=&quot;hljs-built_in&quot;&gt;set&lt;/span&gt;()

    &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; each_result &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; result_set:
        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;not&lt;/span&gt; is_similar(now_check_name, each_result):
            remove_target.add(each_result)

    &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; each_target &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; remove_target:
        result_set.remove(each_target)

&lt;span class=&quot;hljs-comment&quot;&gt;# 후보가 안 남았다면 문구를 출력, 후보가 남았다면 후보 중 하나를 출력한다.&lt;/span&gt;
&lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;not&lt;/span&gt; result_set:
    &lt;span class=&quot;hljs-built_in&quot;&gt;print&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;CALL FRIEND&amp;#x27;&lt;/span&gt;)

&lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;:
    &lt;span class=&quot;hljs-built_in&quot;&gt;print&lt;/span&gt;(result_set.pop())
&lt;/code&gt;&lt;/pre&gt;
</content:encoded></item><item><title>[1Day-1CS] Bottlenecks, classification and analysis of networks</title><link>https://www.traceoflight.dev/en/blog/1day-1cs-26405cdf/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/1day-1cs-26405cdf/</guid><description>1 day 1CS, a quick recap on classifying and analyzing bottlenecks and networks</description><pubDate>Sun, 23 Apr 2023 13:06:14 GMT</pubDate><content:encoded>&lt;h3&gt;Bottleneck&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;A situation where the performance or capacity of an entire system is limited by one component.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Caused by high traffic when opening events on the server and not well managed&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Requires information about the network topology to properly troubleshoot bottlenecks&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The main causes of bottlenecks&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Network bandwidth&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Network topology&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Server CPU, memory usage&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Inefficient network configuration&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Categorize your network&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Networks are categorized based on size&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Local Area Network (LAN)&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Local Area Network&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Fast and uncongested transmission speeds&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Metropolitan Area Network (MAN)&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Metropolitan area network&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Transmission speed is average, more congested than LAN&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Wide Area Network (WAN)&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Wide area network&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Slower transmission speed, more congested than MAN&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Network Performance Analysis Commands&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;ping&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Sends a certain size packet to the target node whose status you want to check&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;netstat&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Displays the network status of connected services&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;netstat * Shows a list of network connections, routing tables, network protocols, etc.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;nslookup&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Used to look up DNS-related content&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;tracert (traceroute)&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Used to verify the network route to the destination node&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Can be used to see where response times are slowing down, etc.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Many other commands exist and use programs like wireshark, netmon, etc.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
</content:encoded></item><item><title>[1Day-1CS] Network Topology</title><link>https://www.traceoflight.dev/en/blog/1day-1cs-21436c11/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/1day-1cs-21436c11/</guid><description>Day 1 1CS, A quick refresher on network topology patterns</description><pubDate>Thu, 20 Apr 2023 12:56:24 GMT</pubDate><content:encoded>&lt;h3&gt;Network Topology&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;How the nodes and links are arranged and how they are connected.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Tree topology&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Hierarchical topology, a network organization laid out in the form of a tree.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Easy to add and delete nodes&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Concentration of traffic on a particular node affects subordinate nodes&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Bus Topology&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Connecting multiple nodes to one centralized communication line&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Used for local area networks&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Low installation cost, high reliability, and easy to add and remove nodes to the centralized communication line&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Spoofing issues exist&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;Spoofing:
&lt;strong&gt;to another host on the LAN that is not involved in the transmission&lt;/strong&gt;.
&lt;strong&gt;paralyzing or tricking a switch&apos;s ability to prevent the packet from going to&lt;/strong&gt;
&lt;strong&gt;treating a packet as if it were coming from a specific node&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Star topology&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;A network configuration where everyone is connected to a centrally located node.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Easy to add nodes or detect errors&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Packets are less likely to collide&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Entire network is unavailable in the event of a central node failure&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;High installation cost&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Ring Topology&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Moving data from node to node, processing packets through a ring-shaped path&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Little loss on the network as the number of nodes increases&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Less likely to crash and easier to detect node failures&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Difficult to change network configuration&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Failure affects the entire network&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Mesh topology&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Mesh topology, a reticulated connection structure&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Multiple paths exist to keep the network up and running if one terminal fails&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Possibility to distribute traffic&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Difficult to add nodes and expensive to build and operate&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
</content:encoded></item><item><title>[1Day-1CS] Network startup, throughput and latency</title><link>https://www.traceoflight.dev/en/blog/1day-1cs-4b2e3588/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/1day-1cs-4b2e3588/</guid><description>1CS per day, a quick refresher on throughput and latency</description><pubDate>Mon, 17 Apr 2023 14:32:41 GMT</pubDate><content:encoded>&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;It&apos;s that time of the year again, and I&apos;ve been so busy lately, but I think it helps to keep studying, so I&apos;m going to try my best!&lt;/p&gt;
&lt;h3&gt;Network&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;A set of nodes and links that are only connected to each other or share connections and resources.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Node: A device such as a server, router, switch, etc.
Link: Wireless or wired&lt;/p&gt;
&lt;h3&gt;Throughput and latency&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;A network that can handle a lot of throughput, has low latency, fewer failures, and good security&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Throughput: The amount of data successfully passed within a link.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Traffic: The amount of data flowing within a link at any given time.
→ More traffic = more data flowing.
→ More throughput = more traffic being processed.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;Throughput is affected by traffic, bandwidth, network-induced errors, and device specs&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Latency: The time a request is processed, measured in round trips.&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;Latency is affected by the type of medium, the size of the packet, and the router&apos;s packet processing time&lt;/p&gt;
&lt;/blockquote&gt;
</content:encoded></item><item><title>[1Day-1CS] Design Patterns &amp; Paradigms Cleanup</title><link>https://www.traceoflight.dev/en/blog/1day-1cs-5e78c961/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/1day-1cs-5e78c961/</guid><description>1 day 1Bulk up on CS, design patterns, and programming paradigms</description><pubDate>Mon, 10 Apr 2023 16:56:14 GMT</pubDate><content:encoded>&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;Everything I&apos;m organizing now is based on &amp;quot;CS Major Knowledge Notes for Interview&amp;quot;. Actually, I think I should have mentioned it at the beginning of Day 1 CS, but I&apos;m writing it now.&lt;/p&gt;
&lt;h3&gt;Design Patterns&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Conventions created to solve problems that occurred when designing a program through object interrelationships, etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;Singleton pattern: utilizing dependency injectors to solve the 1-class 1-stance / module binding issue&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;Factory Pattern: Parent class provides the big picture and subclasses refine it through inheritance&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;Strategy Pattern: Leverage encapsulated algorithms by swapping them around inside the context&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;Observer pattern: observes state changes and communicates changes through methods, etc.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;Proxy pattern: acting as an interface to intercept the flow before accessing the target object&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;Iterator pattern: accessing elements of a collection using an iterator, allowing traversal through a single interface.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;ExposureModule pattern: a pattern for creating access controllers&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;MVC pattern: consists of a Model, View, and Controller, allowing you to develop the components of your application in a compartmentalized manner.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;MVP pattern: Replaces only the Controller with a Presenter&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;MVVM pattern: Replaces only Controller with View Model&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Programming paradigm&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Declarative vs. Imperative
→ What is declarative and what is imperative?&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Declarative&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Functional programming: Stacking pure functions to implement logic&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Imperative&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Object-oriented programming: express the interaction of objects, leverage object methods&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Procedure-oriented programming: consists of continuous computation, satisfied by verbatim implementation of code&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
</content:encoded></item><item><title>[1Day-1CS] Procedural Programming &amp;amp; Mixing Paradigms</title><link>https://www.traceoflight.dev/en/blog/1day-1cs-fbf17eb9/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/1day-1cs-fbf17eb9/</guid><description>A Brief Summary of &amp;quot;1 Day, 1 CS,&amp;quot; Procedural Programming, and Choosing a Programming Paradigm</description><pubDate>Sat, 08 Apr 2023 15:32:23 GMT</pubDate><content:encoded>&lt;h3&gt;Procedural Programming&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Consists of a sequential series of computational steps that the logic must perform&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Since the code is implemented exactly as the process unfolds, it offers good readability and fast execution speed&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Disadvantages include difficulty in modularization and poor maintainability&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Choosing a Paradigm&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;There is no such thing as an absolute superiority among paradigms&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Choose a paradigm based on the characteristics of the service or the business logic&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;It is also advisable to select a paradigm based on the specific logic involved&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
</content:encoded></item><item><title>[1Day-1CS] Design Principles of OOP</title><link>https://www.traceoflight.dev/en/blog/1day-1cs-oop/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/1day-1cs-oop/</guid><description>1 CS a Day: A Brief Summary of Design Principles in Object-Oriented Programming</description><pubDate>Thu, 06 Apr 2023 12:27:00 GMT</pubDate><content:encoded>&lt;h3&gt;Single Responsibility Principle&lt;/h3&gt;
&lt;p&gt;Single Responsibility Principle&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Every class should have only one responsibility.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Open-Closed Principle&lt;/h3&gt;
&lt;p&gt;Open-Closed Principle&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Existing code should be modified as little as possible during maintenance, and it should be easy to extend.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Liskov Substitution Principle&lt;/h3&gt;
&lt;p&gt;Liskov Substitution Principle&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Objects must be replaceable with instances of their subtypes without breaking the program’s correctness. This means that inheritance must function properly without issues.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Interface Segregation Principle&lt;/h3&gt;
&lt;p&gt;Interface Segregation Principle&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Create multiple specific interfaces instead of a single general interface&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Dependency Inversion Principle&lt;/h3&gt;
&lt;p&gt;Dependency Inversion Principle&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The upper layer should be independent of changes in the lower layer; to avoid being affected by elements that change more frequently than itself, a superclass or abstract interface should be used.&lt;/p&gt;
&lt;/blockquote&gt;
</content:encoded></item><item><title>Samsung Software Capability Assessment Type B Review</title><link>https://www.traceoflight.dev/en/blog/samsung-software-competency-evaluation-type-b/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/samsung-software-competency-evaluation-type-b/</guid><description>Take the Samsung Software Competency Assessment all three times and write about your failures.</description><pubDate>Thu, 06 Apr 2023 12:08:47 GMT</pubDate><content:encoded>&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;Let&apos;s start with the bottom line: I&apos;ve missed two out of three opportunities so far. So I&apos;d like to leave you with a few tips on how to succeed in the future.&lt;/p&gt;
&lt;h3&gt;Qualifications&lt;/h3&gt;
&lt;p&gt;I took the mock competency assessment at Samsung Youth Software Academy with a qualification of A.&lt;/p&gt;
&lt;h3&gt;Recap&lt;/h3&gt;
&lt;p&gt;In the past, I felt that not only did I spend too much time on implementation, but I was also lacking in optimization. I have about one more chance to take the exam, and I think I should study a lot about optimization.&lt;/p&gt;
&lt;h4&gt;1. Poor use of objects&lt;/h4&gt;
&lt;p&gt;I was not familiar with object-oriented coding because I was using Python, and I tried to master it a lot, but I still feel that I am not good enough. In particular, I find it difficult to override and use parts such as Comparator...&lt;/p&gt;
&lt;h4&gt;2. Familiarize yourself with the data structure&lt;/h4&gt;
&lt;p&gt;If you listen to the stories of the passers of Type B, they emphasize the material structure a lot, but if you ask me whether I have mastered the material structure enough, I think I need to have enough time to review until the final test because I still have some deficiencies.&lt;/p&gt;
&lt;h3&gt;+ More&lt;/h3&gt;
&lt;p&gt;The end of April marks the end of my 3-month Type B journey. As a result, I didn&apos;t qualify for Type B, which is a shame because I was so close to the final question but couldn&apos;t take that last step.&lt;/p&gt;
&lt;p&gt;But I tried, I tried, I tried, and I think I was able to improve to some degree because I tried.&lt;/p&gt;
&lt;p&gt;This is definitely an advantage when it comes to taking a coding test for a corporate job.&lt;/p&gt;
&lt;p&gt;The qualification I have now is probably a provisional A, so I won&apos;t have the chance to take the B anymore after SSAFY, but it&apos;s nice to have another one over with!&lt;/p&gt;
</content:encoded></item><item><title>[1Day-1CS] Imperative Programming &amp; Object-Oriented Programming</title><link>https://www.traceoflight.dev/en/blog/1day-1cs-cdddda5a/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/1day-1cs-cdddda5a/</guid><description>1 Day 1CS, A Quick Recap of Imperative &amp; Object-Oriented Programming</description><pubDate>Fri, 31 Mar 2023 11:39:05 GMT</pubDate><content:encoded>&lt;h3&gt;Types of imperative programming&lt;/h3&gt;
&lt;h4&gt;Object-Oriented Programming&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A way of representing the interactions of a program as a collection of objects and utilizing methods declared inside the objects.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Time-consuming to design and slower than other programming paradigms&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Features of Object-Oriented Programming&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Abstraction: distilling core concepts, functionality, and functionality from complex systems.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Encapsulation: bundling an object&apos;s properties and methods together and hiding some of them from the outside world.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Inheritance: allowing a child class to inherit the characteristics of a parent class, allowing it to be reused, added to, and extended.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Polymorphism: A single method or class can behave in many different ways.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Overloading: having multiple methods with the same name, &amp;quot;static&amp;quot; polymorphism that occurs during &amp;quot;compilation&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Overriding: A child class overriding a method inherited from a parent class, &apos;dynamic&apos; polymorphism that occurs during &apos;runtime&apos;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
</content:encoded></item><item><title>[1Day-1CS] Declarative Programming</title><link>https://www.traceoflight.dev/en/blog/1day-1cs-dbfa4ad8/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/1day-1cs-dbfa4ad8/</guid><description>1 Day 1CS, A Quick Recap of Declarative Programming</description><pubDate>Fri, 31 Mar 2023 11:36:56 GMT</pubDate><content:encoded>&lt;h3&gt;Programming Paradigms&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;A development methodology that serves to give programmers a perspective on programming.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Declarative vs. Imperative&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Declarative: a paradigm that focuses on solving for what (What)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Imperative: a paradigm that focuses on how to solve (How)&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;Example)
Declarative: the address of your house (specify exactly where it is)
Imperative: the route to the house (showing how to get to the location)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Types of Declarative Programming&lt;/h3&gt;
&lt;h4&gt;Functional Programming&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;A programming paradigm that implements logic by stacking small pure functions like blocks, and higher-order functions for greater reusability.&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Pure functions: A function whose output depends only on its input.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Higher-order functions: Functions that take parameters as values to generate logic.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Higher-order functions can be used if the language is First Class Object.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Characteristics of First Class Objects&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Functions can be assigned to variables or methods&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Can contain functions as parameters inside functions&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Functions can return functions&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
</content:encoded></item><item><title>[1Day-1CS] MVC Patterns and Similar Patterns</title><link>https://www.traceoflight.dev/en/blog/1day-1cs-mvc/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/1day-1cs-mvc/</guid><description>1CS in 1 day, a quick refresher on MVC patterns</description><pubDate>Thu, 30 Mar 2023 16:36:43 GMT</pubDate><content:encoded>&lt;h3&gt;MVC Pattern&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Design pattern consisting of Model, View, Controller&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Divides the components of an application into three parts, allowing you to focus on each component and develop them separately&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Facilitates reusability and determinism&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Has the disadvantage that as the complexity of the application increases, the relationship between Model and View becomes more complex&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Model&lt;/h4&gt;
&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Data in the application, meaning DB, constants, variables, etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;h4&gt;View&lt;/h4&gt;
&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Refers to a user interface element and refers to the screen that a user can see based on the Model&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Doesn&apos;t store any information from the model, only the screen display information&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Passes changes to Controller when they occur&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;h4&gt;Controller&lt;/h4&gt;
&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Acts as a bridge between Model and View&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Responsible for main logic such as Events, and also manages Life Cycle&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;When notified of a change in the Model or View, it delivers the corresponding content to the required components.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;h4&gt;Similar Patterns&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;MVP Pattern: Replaces Controller with Presenter, which has a stronger coupling since the relationship between View and Presenter is 1:1&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;MVVM pattern: Replaces Controller with View Model, has Command and Data Binding, enables UI reusability and easier unit testing&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
</content:encoded></item><item><title>[1Day-1CS] Proxy Patterns &amp; Iterator Patterns &amp; Exposure Module Patterns</title><link>https://www.traceoflight.dev/en/blog/1day-1cs-c6863ddc/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/1day-1cs-c6863ddc/</guid><description>A Quick Recap of 1CS, Proxy Patterns, Iterator Patterns, and Exposure Module Patterns</description><pubDate>Tue, 28 Mar 2023 23:30:10 GMT</pubDate><content:encoded>&lt;h3&gt;Proxy Pattern&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A design pattern that acts as an interface to a target object by intercepting its flow before it is accessed and acting as a front-end to the target object.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Used for security, data validation, caching, and logging; also utilized as a server rather than an object&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Proxy Server&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Works between server and client&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A system or program that allows clients to access other network services indirectly through it.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;Examples include Apache, Nginx, CloudFlare, etc.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4&gt;Example usage of a proxy server&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Go through a proxy, so you can hide the actual port you&apos;re using&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Allows you to gzip static resources through Nginx, or logging in front of your main server&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;CloudFlare makes it easy to deploy HTTPS, which can help defend against DDOS attacks&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Front-end proxy servers can be used to prevent Cross Origin Resource Sharing (CORS) errors&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Iterator Pattern&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Design pattern for accessing elements of a collection through an iterator.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Regardless of the structure of the data types, it is possible to traverse them with one interface: an iterator.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Normally iterable objects can be traversed via the iterator protocol&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Exposed Module Pattern&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Pattern that creates access controllers such as private, public through immediate functions&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;In case of JS, access controllers don&apos;t exist separately, so we also build them by implementing them&lt;/li&gt;
&lt;/ul&gt;
</content:encoded></item><item><title>[1Day-1CS] Factory Pattern, Strategy Pattern, and Observer Pattern</title><link>https://www.traceoflight.dev/en/blog/1day-1cs-f886ff08/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/1day-1cs-f886ff08/</guid><description>A Brief Summary of the Singleton Pattern, Factory Pattern, Strategy Pattern, and Observer Pattern</description><pubDate>Mon, 27 Mar 2023 22:36:03 GMT</pubDate><content:encoded>&lt;h3&gt;Factory Pattern&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A pattern that abstracts the object creation process from the code that uses the objects&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The superclass determines the essential framework&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The subclass determines the specific details of object creation&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Characteristics and Advantages of the Factory Pattern&lt;/h4&gt;
&lt;blockquote&gt;
&lt;p&gt;Achieves loose coupling through class separation
Ensures flexibility in the superclass and improves maintainability&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Strategy Pattern&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Do not modify the object directly if you do not want to change its behavior&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Designed to allow replacement by changing the &lt;strong&gt;encapsulated algorithm&lt;/strong&gt; corresponding to the strategy within the context&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;Context&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Refers to the relevant information required for a developer to complete a task&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;There exists a mandatory context essential for an action to occur, as well as an optional context for the effective execution of the action.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Observer Pattern&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A subject observes state changes in a specific object&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;When a state change occurs, the subject notifies observers of the change via methods, etc.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Sometimes built based on mutable objects rather than separating the subject and the object&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Also utilized in the MVC pattern&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
</content:encoded></item><item><title>[1Day-1CS] Singleton Patterns</title><link>https://www.traceoflight.dev/en/blog/1day-1cs/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/1day-1cs/</guid><description>1 day 1CS, a quick recap of the singleton pattern</description><pubDate>Mon, 27 Mar 2023 15:29:32 GMT</pubDate><content:encoded>&lt;h3&gt;What are design patterns?&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;A problem exists when designing a program
→ Create a convention to solve it by using interrelationships between objects, etc.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Singleton Pattern&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;One class = one instance&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;We could create multiple separate instances per class, but we don&apos;t, we use only one&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Usually used for DB modules&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Productivity ↑, dependency ↓&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Disadvantages of the Singleton Pattern&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Possibility of issues when running unit tests during Test Driven Development (TDD)&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;Difficult to create an independent instance for each test due to the highly dependent nature of the singleton pattern&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Dependency Injection&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A way to address the disadvantages of the singleton pattern&apos;s strong coupling between modules.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Instead of the main module directly giving dependencies to other submodules, it injects dependencies indirectly through a &lt;strong&gt;dependency injector&lt;/strong&gt; (decoupling)&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Advantages&lt;/h4&gt;
&lt;blockquote&gt;
&lt;p&gt;Easier to replace modules, Easier to test &amp;amp; migrate, Consistency in dependency orientation, Easier to reason about application, Clarity of relationships, etc.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4&gt;Cons&lt;/h4&gt;
&lt;blockquote&gt;
&lt;p&gt;Modules are more decoupled → Increased complexity due to increased number of classes, runtime penalty&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4&gt;Principles of Dependency Injection&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Parent module does not import anything from child modules&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Both must rely on an abstraction + Abstraction does not depend on details&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
</content:encoded></item><item><title>[CI/CD] A Guide to Automated Deployment of FastAPI Servers Using Docker, Jenkins, and Git Webhooks</title><link>https://www.traceoflight.dev/en/blog/cicd-docker-jenkins-git-webhook/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/cicd-docker-jenkins-git-webhook/</guid><description>Implementing Production-Ready Automated Deployment</description><pubDate>Fri, 24 Mar 2023 02:08:12 GMT</pubDate><content:encoded>&lt;blockquote&gt;
&lt;p&gt;Notes in progress &amp;gt; First update completed as of May 2023
&lt;a href=&quot;/blog/ci-cd-dood-feat-nginx-jenkins&quot;&gt;For deployment-related content, please refer to part 2 which is more polished.&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Intro&lt;/h3&gt;
&lt;p&gt;While working on a current project, I was building a service that exposes outputs powered by an AI model.&lt;/p&gt;
&lt;p&gt;I wanted to build that feature on Firebase Cloud Functions, but loading the model with nodeJS + tensorflow.js forced model conversion, the runtime was inherently heavy and kept timing out — for various reasons it kept getting blocked, so I decided to build a small server that returns results from the AI model.&lt;/p&gt;
&lt;p&gt;That meant the server build and deployment fell on me, and as a first goal I aimed to get automated deployment working, then later push toward zero-downtime deployment with my own hands.&lt;/p&gt;
&lt;p&gt;This post only covers the system build on top of an instance such as AWS and the automated deployment.&lt;/p&gt;
&lt;h3&gt;Background concepts&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;CI: Continuous Integration&lt;/p&gt;
&lt;p&gt;An automated process for developers in which code changes go through build and test and are regularly merged into a shared repository. Automating this process is used as a way to reduce risk during development.&lt;/p&gt;
&lt;p&gt;Composed of CI Server, Source Control Management, Build Tool, Test Tool, etc.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;CD: Continuous Delivery / Deployment&lt;/p&gt;
&lt;p&gt;Refers to the deployment automation process. By automating the additional pipeline stages, changes can flow all the way to production without manual intervention. Continuous Integration must back it up, and once a reliable environment is in place, multiple releases per day become possible.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;As a result, going through this CI/CD process shortens the time to product release, increases workforce efficiency, and reduces the chance of major issues because everything is a chain of incremental, continuous steps.&lt;/p&gt;
&lt;h3&gt;Setting up the Docker environment&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Instance info&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;Instead of the EC2 free tier, I went with Oracle Cloud&apos;s free tier, which has relatively better terms.
Allocated and used an arm64 Ampere A1 Compute with 2 cores and 12GB RAM.&lt;/p&gt;
&lt;p&gt;It also provides things like backups for free to some extent — worth checking out!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Linux setup
&lt;a href=&quot;https://bgpark.tistory.com/85&quot;&gt;How to connect to EC2 with a password&lt;/a&gt; - an article about ssh setup for login convenience
&lt;a href=&quot;https://docs.docker.com/engine/install/ubuntu/&quot;&gt;Docker installation&lt;/a&gt; - the official Docker install DOCS for Ubuntu&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I gathered the references I used. There are plenty of articles about installing Docker and setting up the instance, so look them up and set up Docker accordingly.&lt;/p&gt;
&lt;h3&gt;Setting up Docker in Docker (failed &amp;gt; switched to Docker out of Docker via the API)&lt;/h3&gt;
&lt;h4&gt;Why use it&lt;/h4&gt;
&lt;p&gt;The reason for handling Docker on top of Docker is to control containers through a container, and while the privileges of that container become very strong (which raises security concerns), the approach itself is undeniably appealing.&lt;/p&gt;
&lt;h4&gt;The setup I tried&lt;/h4&gt;
&lt;h5&gt;1. Build a Jenkins container on Docker&lt;/h5&gt;
&lt;p&gt;First, build the Jenkins container with Docker.
Using Docker Compose makes the build a bit easier, so keep that in mind.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;docker pull jenkins/jenkins:lts

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;First pull the Jenkins LTS container.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;vim docker-compose.yml
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Create or open the yml file with that command.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-yml&quot;&gt;&lt;span class=&quot;hljs-attr&quot;&gt;version:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;2.5.0&amp;quot;&lt;/span&gt; &lt;span class=&quot;hljs-comment&quot;&gt;# specify the compose version&lt;/span&gt;

&lt;span class=&quot;hljs-attr&quot;&gt;services:&lt;/span&gt;

  &lt;span class=&quot;hljs-attr&quot;&gt;jenkins:&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;container_name:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;jenkins&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;image:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;jenkins/jenkins:lts&lt;/span&gt; &lt;span class=&quot;hljs-comment&quot;&gt;# use the Jenkins LTS image&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;restart:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;always&lt;/span&gt; &lt;span class=&quot;hljs-comment&quot;&gt;# auto-restart option&lt;/span&gt;

    &lt;span class=&quot;hljs-attr&quot;&gt;ports:&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;8181:8080&amp;quot;&lt;/span&gt; &lt;span class=&quot;hljs-comment&quot;&gt;# map host port 8181 to Jenkins port 8080&lt;/span&gt;

    &lt;span class=&quot;hljs-attr&quot;&gt;volumes:&lt;/span&gt; &lt;span class=&quot;hljs-comment&quot;&gt;# share host volumes through this option&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;/home/opendocs/jenkins:/var/jenkins_home&lt;/span&gt;
      &lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;/var/run/docker.sock:/var/run/docker.sock&lt;/span&gt;

    &lt;span class=&quot;hljs-attr&quot;&gt;user:&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;root&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;privileged:&lt;/span&gt; &lt;span class=&quot;hljs-literal&quot;&gt;true&lt;/span&gt; &lt;span class=&quot;hljs-comment&quot;&gt;# the key option to enable Docker in Docker&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Fill in the yml file with the necessary content like the example.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;docker-compose -f {filename} up
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This command runs the setup based on docker-compose.yml. If you keep the default name docker-compose.yml, you can omit the -f option. See the Docker Compose Docs for details.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://docs.docker.com/compose/&quot;&gt;Docker Compose Documents&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;+ How to use docker without sudo → add the current user to the Docker group&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;# this command adds the current user to the Docker group&lt;/span&gt;
&lt;span class=&quot;hljs-built_in&quot;&gt;sudo&lt;/span&gt; usermod -aG docker &lt;span class=&quot;hljs-variable&quot;&gt;$USER&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;h5&gt;2. Setting up the Jenkins Container&lt;/h5&gt;
&lt;ol&gt;
&lt;li&gt;Open the configured IP and the assigned Port Number in a browser&lt;/li&gt;
&lt;li&gt;Enter the key shown in the Jenkins install log on the screen&lt;/li&gt;
&lt;/ol&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;# this command lets you check the container logs&lt;/span&gt;
docker logs jenkins
&lt;/code&gt;&lt;/pre&gt;
&lt;ol&gt;
&lt;li&gt;Install the recommended plugins&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You may run into issues, but for now finish the install and resolve them afterwards.
If you don&apos;t finish, dependency errors caused by uninstalled plugins keep coming up...&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://wingsh.tistory.com/261&quot;&gt;Workaround for plugin install timeouts&lt;/a&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Install the GitHub API Plugin&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;A plugin that lets webhook triggers work. Install it. After installing, register your Git ID/PW as a Secret.&lt;/p&gt;
&lt;h5&gt;3. GitHub configuration&lt;/h5&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Create a Token under Settings &amp;gt; Developer Settings. As of writing, I use a Classic token, and only repo and admin:repo_hook permissions are needed.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In the settings of the repo to be auto-deployed, add a Webhook under Webhooks. Setting it to roughly http://{jenkins_url}/github-webhook/ works. Leaving off the trailing / can cause problems, so just keep it.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h5&gt;4. Setting up the Jenkins project&lt;/h5&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Add a project.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Under build configuration &amp;gt; source code management, choose Git and pick the previously registered Secret to receive webhook signals.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You must select the GitHub hook trigger for GITScm polling option for the trigger to fire.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Pick the branch as needed, finish the configuration, and run a test.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
</content:encoded></item><item><title>[BOJ 4803, Java] Tree</title><link>https://www.traceoflight.dev/en/blog/boj4803/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/boj4803/</guid><description>Java Solution for BOJ Problem 4803, &amp;quot;Tree&amp;quot;</description><pubDate>Tue, 28 Feb 2023 00:26:49 GMT</pubDate><content:encoded>&lt;h3&gt;Problem Link&lt;/h3&gt;
&lt;p&gt;[BOJ 4803](&lt;a href=&quot;https://www.acmicpc.net/problem/4803&quot;&gt;https://www.acmicpc.net/problem/4803&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;h3&gt;Categories&lt;/h3&gt;
&lt;p&gt;Data Structures, Depth-First Search (DFS), Disjoint Sets, Graph Theory, Graph Traversal, Trees&lt;/p&gt;
&lt;h3&gt;Description&lt;/h3&gt;
&lt;p&gt;This problem involved counting the number of trees using tree properties. It can be solved by excluding cycles from the set of connected elements.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Check if every node has been visited&lt;/li&gt;
&lt;li&gt;Perform depth-first search while adding unvisited nodes to the tree&lt;/li&gt;
&lt;li&gt;If a cycle is formed, mark all nodes in the cycle as visited&lt;/li&gt;
&lt;li&gt;If no cycle is formed, the set is a tree, so count it as 1&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I implemented the logic described above. After much deliberation on how to handle the counting during depth-first search, I wrote the following code:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-java&quot;&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;dfs&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; nowNode, &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; parent, &lt;span class=&quot;hljs-type&quot;&gt;boolean&lt;/span&gt;[] visitLog, HashMap&amp;lt;Integer, ArrayList&amp;lt;Integer&amp;gt;&amp;gt; graph)&lt;/span&gt; {

        &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; nextNode : graph.get(nowNode)) {

            &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (nextNode != parent &amp;amp;&amp;amp; !visitLog[nextNode]) {

                visitLog[nextNode] = &lt;span class=&quot;hljs-literal&quot;&gt;true&lt;/span&gt;;

                &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; dfs(nextNode, nowNode, visitLog, graph);
                &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (result == &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;) {
                    &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;;
                }

            } &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (nextNode != parent &amp;amp;&amp;amp; visitLog[nextNode]) {
                &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;;
            }

        }

        &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;;

    }

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I wrote the code to start from the root node and perform a recursive search; if a cycle is encountered, it traverses all nodes and returns 0.&lt;/p&gt;
&lt;p&gt;If no cycle is found, the traversal completes normally and returns 1. By continuously counting these return values, we can determine the number of trees!&lt;/p&gt;
&lt;h3&gt;Solution Code&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-java&quot;&gt;
&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; java.io.*;
&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; java.util.*;

&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;Main&lt;/span&gt; {

    &lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;dfs&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; nowNode, &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; parent, &lt;span class=&quot;hljs-type&quot;&gt;boolean&lt;/span&gt;[] visitLog, HashMap&amp;lt;Integer, ArrayList&amp;lt;Integer&amp;gt;&amp;gt; graph)&lt;/span&gt; {

        &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; nextNode : graph.get(nowNode)) {

            &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (nextNode != parent &amp;amp;&amp;amp; !visitLog[nextNode]) {

                visitLog[nextNode] = &lt;span class=&quot;hljs-literal&quot;&gt;true&lt;/span&gt;;

                &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; dfs(nextNode, nowNode, visitLog, graph);
                &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (result == &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;) {
                    &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;;
                }

            } &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (nextNode != parent &amp;amp;&amp;amp; visitLog[nextNode]) {
                &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;;
            }

        }

        &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;;

    }

    &lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(String[] args)&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;throws&lt;/span&gt; IOException {

        &lt;span class=&quot;hljs-type&quot;&gt;BufferedReader&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;input&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;BufferedReader&lt;/span&gt;(&lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;InputStreamReader&lt;/span&gt;(System.in));
        &lt;span class=&quot;hljs-type&quot;&gt;BufferedWriter&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;output&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;BufferedWriter&lt;/span&gt;(&lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;OutputStreamWriter&lt;/span&gt;(System.out));

        &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;testCase&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;;

        ArrayList&amp;lt;String&amp;gt; outputArr = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;ArrayList&lt;/span&gt;&amp;lt;&amp;gt;();

        &lt;span class=&quot;hljs-keyword&quot;&gt;while&lt;/span&gt; (&lt;span class=&quot;hljs-literal&quot;&gt;true&lt;/span&gt;) {

            &lt;span class=&quot;hljs-type&quot;&gt;StringTokenizer&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;treeInfo&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;StringTokenizer&lt;/span&gt;(input.readLine(), &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;[ ]&amp;quot;&lt;/span&gt;);
            &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;nodeNumber&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; Integer.parseInt(treeInfo.nextToken());
            &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;edgeNumber&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; Integer.parseInt(treeInfo.nextToken());

            &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (nodeNumber == &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt; &amp;amp;&amp;amp; edgeNumber == &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;) {
                &lt;span class=&quot;hljs-keyword&quot;&gt;break&lt;/span&gt;;
            }

            testCase += &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;;

            &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;treeCount&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;;
            &lt;span class=&quot;hljs-type&quot;&gt;boolean&lt;/span&gt;[] isVisited = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;boolean&lt;/span&gt;[nodeNumber + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;];

            &lt;span class=&quot;hljs-type&quot;&gt;StringBuilder&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;stringBuilder&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;StringBuilder&lt;/span&gt;();
            stringBuilder.append(&lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;Case &amp;quot;&lt;/span&gt;);
            stringBuilder.append(testCase);
            stringBuilder.append(&lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;: &amp;quot;&lt;/span&gt;);

            HashMap&amp;lt;Integer, ArrayList&amp;lt;Integer&amp;gt;&amp;gt; treeGraph = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;HashMap&lt;/span&gt;&amp;lt;&amp;gt;();
            &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;; i &amp;lt; nodeNumber + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;; i++) {
                treeGraph.put(i, &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;ArrayList&lt;/span&gt;&amp;lt;&amp;gt;());
            }

            &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; i &amp;lt; edgeNumber; i++) {

                &lt;span class=&quot;hljs-type&quot;&gt;StringTokenizer&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;edgeInfo&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;StringTokenizer&lt;/span&gt;(input.readLine(), &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;[ ]&amp;quot;&lt;/span&gt;);
                &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;startNode&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; Integer.parseInt(edgeInfo.nextToken());
                &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;endNode&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; Integer.parseInt(edgeInfo.nextToken());

                treeGraph.get(startNode).add(endNode);
                treeGraph.get(endNode).add(startNode);

            }

            &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;; i &amp;lt; nodeNumber + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;; i++) {

                isVisited[i] = &lt;span class=&quot;hljs-literal&quot;&gt;true&lt;/span&gt;;
                treeCount += dfs(i, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, isVisited, treeGraph);
            }

            &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (treeCount == &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;) {
                stringBuilder.append(&lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;No trees.&amp;quot;&lt;/span&gt;);
            } &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (treeCount == &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;) {
                stringBuilder.append(&lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;There is one tree.&amp;quot;&lt;/span&gt;);
            } &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (treeCount &amp;gt; &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;) {
                stringBuilder.append(&lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;A forest of &amp;quot;&lt;/span&gt;);
                stringBuilder.append(treeCount);
                stringBuilder.append(&lt;span class=&quot;hljs-string&quot;&gt;&amp;quot; trees.&amp;quot;&lt;/span&gt;);
            }

            outputArr.add(stringBuilder.toString());

        }

        &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; i &amp;lt; testCase; i++) {

            &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (i != testCase - &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;) {
                output.write(outputArr.get(i) + &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;\n&amp;quot;&lt;/span&gt;);
            } &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt; {
                output.write(outputArr.get(i));
            }

        }

        output.flush();
        output.close();

    }

}

&lt;/code&gt;&lt;/pre&gt;
</content:encoded></item><item><title>[BOJ 1485, Python] Square</title><link>https://www.traceoflight.dev/en/blog/boj1485/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/boj1485/</guid><description>Python Solution to BOJ Problem 1485, &amp;quot;Square&amp;quot;</description><pubDate>Sat, 25 Feb 2023 03:05:13 GMT</pubDate><content:encoded>&lt;h3&gt;Problem Link&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/1485&quot;&gt;BOJ 1485&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Categories&lt;/h3&gt;
&lt;p&gt;Geometry, Sorting&lt;/p&gt;
&lt;h3&gt;Description&lt;/h3&gt;
&lt;p&gt;You can determine whether a shape is a square by following these steps.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Check the lengths of all 6 edges connecting the 4 points&lt;/li&gt;
&lt;li&gt;Sort them&lt;/li&gt;
&lt;li&gt;Check if the first 4 lengths are equal&lt;/li&gt;
&lt;li&gt;Check if the last 2 lengths are suitable as the diagonals of a square&lt;/li&gt;
&lt;li&gt;Only if all conditions are satisfied, treat it as a valid square&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Solution Code&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;# 정사각형&lt;/span&gt;

&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; sys
&lt;span class=&quot;hljs-keyword&quot;&gt;from&lt;/span&gt; math &lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; sqrt, isclose
&lt;span class=&quot;hljs-keyword&quot;&gt;from&lt;/span&gt; itertools &lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; combinations

&lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt; = sys.stdin.readline

&lt;span class=&quot;hljs-keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;distance&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;coord_1: &lt;span class=&quot;hljs-built_in&quot;&gt;list&lt;/span&gt;, coord_2: &lt;span class=&quot;hljs-built_in&quot;&gt;list&lt;/span&gt;&lt;/span&gt;) -&amp;gt; &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;:
    &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; sqrt(&lt;span class=&quot;hljs-built_in&quot;&gt;pow&lt;/span&gt;(coord_1[&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;] - coord_2[&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;], &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;) + &lt;span class=&quot;hljs-built_in&quot;&gt;pow&lt;/span&gt;(coord_1[&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;] - coord_2[&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;], &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;))

testcase = &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt;())

output = []

&lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; _ &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(testcase):

    is_square = &lt;span class=&quot;hljs-literal&quot;&gt;True&lt;/span&gt;

    coord_info = []

    &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; _ &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(&lt;span class=&quot;hljs-number&quot;&gt;4&lt;/span&gt;):
        coord_info.append(&lt;span class=&quot;hljs-built_in&quot;&gt;list&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;map&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;, &lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt;().split())))

    edge_info = []

    &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; edge_distance &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; combinations(coord_info, &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;):
        edge_info.append(distance(edge_distance[&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;], edge_distance[&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;]))

    edge_info.sort()

    &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; idx &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;4&lt;/span&gt;):
        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;not&lt;/span&gt; isclose(edge_info[&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;], edge_info[idx]):
            is_square = &lt;span class=&quot;hljs-literal&quot;&gt;False&lt;/span&gt;
            &lt;span class=&quot;hljs-keyword&quot;&gt;break&lt;/span&gt;

    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; is_square:
        &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; idx &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(&lt;span class=&quot;hljs-number&quot;&gt;4&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;6&lt;/span&gt;):
            &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;not&lt;/span&gt; isclose(&lt;span class=&quot;hljs-built_in&quot;&gt;pow&lt;/span&gt;(edge_info[&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;], &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;) * &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;, &lt;span class=&quot;hljs-built_in&quot;&gt;pow&lt;/span&gt;(edge_info[idx], &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;)):
                is_square = &lt;span class=&quot;hljs-literal&quot;&gt;False&lt;/span&gt;
                &lt;span class=&quot;hljs-keyword&quot;&gt;break&lt;/span&gt;

    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; is_square:
        output.append(&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;)

    &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;:
        output.append(&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;)

&lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; result &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; output:
    &lt;span class=&quot;hljs-built_in&quot;&gt;print&lt;/span&gt;(result)
&lt;/code&gt;&lt;/pre&gt;
</content:encoded></item><item><title>[BOJ 12850, Java] Walking the Main Campus 2</title><link>https://www.traceoflight.dev/en/blog/boj12850/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/boj12850/</guid><description>BOJ 12850, Java solution of the &quot;Walk around the University 2&quot; problem</description><pubDate>Wed, 22 Feb 2023 14:05:40 GMT</pubDate><content:encoded>&lt;h3&gt;Problem link&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;@@tlp1@@&quot;&gt;boj 12850&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Classification&lt;/h3&gt;
&lt;p&gt;Exponentiation_by_squaring, Graph theory, Graphs, Mathematics, Division and Conquest&lt;/p&gt;
&lt;h3&gt;Description&lt;/h3&gt;
&lt;h4&gt;Devide and Conquer&lt;/h4&gt;
&lt;p&gt;An algorithm that solves an intractable problem by breaking it down into smaller problems.&lt;/p&gt;
&lt;p&gt;This problem can be solved by drawing a neighboring matrix and knowing that the number of times you can reach the destination is the number of times you can perform n squared operations on the neighboring matrix.&lt;/p&gt;
&lt;p&gt;It does require some study of divide-and-conquer and matrix operations, but I found it to be a reasonable level of difficulty, combining several lower-level problems.&lt;/p&gt;
&lt;h3&gt;Solution code&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-java&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; java.io.*;
&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; java.util.*;

&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;Main&lt;/span&gt; {

    &lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;static&lt;/span&gt; HashMap&amp;lt;Integer, &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;[][]&amp;gt; matrixRecord = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;HashMap&lt;/span&gt;&amp;lt;&amp;gt;();

    &lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;[][] matrixCalculation(&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;[][] matrix1, &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;[][] matrix2) {
        &lt;span class=&quot;hljs-comment&quot;&gt;/* 행렬 연산 함수 */&lt;/span&gt;

        &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;[][] resultArr = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;int&lt;/span&gt;[&lt;span class=&quot;hljs-number&quot;&gt;8&lt;/span&gt;][&lt;span class=&quot;hljs-number&quot;&gt;8&lt;/span&gt;];

        &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; i &amp;lt; &lt;span class=&quot;hljs-number&quot;&gt;8&lt;/span&gt;; i++) {
            &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;j&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; j &amp;lt; &lt;span class=&quot;hljs-number&quot;&gt;8&lt;/span&gt;; j++) {

                &lt;span class=&quot;hljs-type&quot;&gt;long&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;sum&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;;

                &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;k&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; k &amp;lt; &lt;span class=&quot;hljs-number&quot;&gt;8&lt;/span&gt;; k++) {
                    sum += ((&lt;span class=&quot;hljs-type&quot;&gt;long&lt;/span&gt;) matrix1[i][k] * (&lt;span class=&quot;hljs-type&quot;&gt;long&lt;/span&gt;) matrix2[k][j]) % &lt;span class=&quot;hljs-number&quot;&gt;1000000007&lt;/span&gt;;
                }

                resultArr[i][j] = (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;) (sum % &lt;span class=&quot;hljs-number&quot;&gt;1000000007&lt;/span&gt;);

            }
        }

        &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; resultArr;
    }

    &lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;[][] matrixDivision(HashMap&amp;lt;Integer, &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;[][]&amp;gt; matrixInfo, &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; calculationCount) {
        &lt;span class=&quot;hljs-comment&quot;&gt;/* 분할 정복을 통한 행렬 연산 함수 */&lt;/span&gt;

        &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;halfCount&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; calculationCount / &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;;

        &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;[][] halfMatrix;
        &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;[][] otherHalfMatrix;

        &lt;span class=&quot;hljs-comment&quot;&gt;// 기존 값이 존재할 경우 불러오기&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (matrixInfo.containsKey(halfCount)) {
            halfMatrix = matrixInfo.get(halfCount);
        } &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt; {
            halfMatrix = matrixDivision(matrixInfo, halfCount);
        }

        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (matrixInfo.containsKey(calculationCount - halfCount)) {
            otherHalfMatrix = matrixInfo.get(calculationCount - halfCount);
        } &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt; {
            otherHalfMatrix = matrixDivision(matrixInfo, calculationCount - halfCount);
        }

        &lt;span class=&quot;hljs-comment&quot;&gt;// 연산 후 행렬 반환&lt;/span&gt;
        &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;[][] calculationResult = matrixCalculation(halfMatrix, otherHalfMatrix);
        matrixInfo.putIfAbsent(calculationCount, calculationResult);

        &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; calculationResult;
    }

    &lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(String[] args)&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;throws&lt;/span&gt; IOException {

        &lt;span class=&quot;hljs-type&quot;&gt;BufferedReader&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;input&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;BufferedReader&lt;/span&gt;(&lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;InputStreamReader&lt;/span&gt;(System.in));
        &lt;span class=&quot;hljs-type&quot;&gt;BufferedWriter&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;output&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;BufferedWriter&lt;/span&gt;(&lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;OutputStreamWriter&lt;/span&gt;(System.out));

        &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;walkTime&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; Integer.parseInt(input.readLine());

        &lt;span class=&quot;hljs-comment&quot;&gt;// 기본 행렬 및 본대 인접 행렬 선언&lt;/span&gt;
        &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;[][] baseMatrix = {
                {&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;},
                {&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;},
                {&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;},
                {&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;},
                {&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;},
                {&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;},
                {&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;},
                {&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;},
        };

        &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;[][] graph = {
                {&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;},
                {&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;},
                {&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;},
                {&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;},
                {&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;},
                {&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;},
                {&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;},
                {&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;},
        };

        &lt;span class=&quot;hljs-comment&quot;&gt;// 해시맵에 초기값들 등록&lt;/span&gt;
        matrixRecord.put(&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, baseMatrix);
        matrixRecord.put(&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, graph);

        &lt;span class=&quot;hljs-comment&quot;&gt;// 함수를 통해 분할정복 연산 실행&lt;/span&gt;
        matrixDivision(matrixRecord, walkTime);

        &lt;span class=&quot;hljs-comment&quot;&gt;// 결과 출력&lt;/span&gt;
        output.write(Integer.toString(matrixRecord.get(walkTime)[&lt;span class=&quot;hljs-number&quot;&gt;7&lt;/span&gt;][&lt;span class=&quot;hljs-number&quot;&gt;7&lt;/span&gt;]));

        output.flush();
        output.close();

    }

}
&lt;/code&gt;&lt;/pre&gt;
</content:encoded></item><item><title>Refactoring 1 - 1. Type &apos;...&apos; is not assignable to type &quot;...&quot;</title><link>https://www.traceoflight.dev/en/blog/refactoring-1-1/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/refactoring-1-1/</guid><description>Type &apos;string&apos; is not assignable to type &apos;&quot;text&quot; | &quot;outlined&quot; | &quot;contained&quot; | undefined&apos;.&quot; Resolving the error</description><pubDate>Tue, 21 Feb 2023 16:40:07 GMT</pubDate><content:encoded>&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;&amp;lt;&lt;span class=&quot;hljs-title class_&quot;&gt;Button&lt;/span&gt;
onClick={handleLogin}
variant=&lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;contained&amp;quot;&lt;/span&gt;
  &amp;gt;
    &lt;span class=&quot;hljs-variable constant_&quot;&gt;LOGIN&lt;/span&gt;
&amp;lt;/&lt;span class=&quot;hljs-title class_&quot;&gt;Button&lt;/span&gt;&amp;gt;
&lt;span class=&quot;language-xml&quot;&gt;&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;&lt;span class=&quot;hljs-name&quot;&gt;Button&lt;/span&gt; &lt;span class=&quot;hljs-attr&quot;&gt;onClick&lt;/span&gt;=&lt;span class=&quot;hljs-string&quot;&gt;{handleGoogleLogin}&lt;/span&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;&lt;span class=&quot;hljs-name&quot;&gt;img&lt;/span&gt;
&lt;span class=&quot;hljs-attr&quot;&gt;src&lt;/span&gt;=&lt;span class=&quot;hljs-string&quot;&gt;{logoSrc}&lt;/span&gt;
&lt;span class=&quot;hljs-attr&quot;&gt;alt&lt;/span&gt;=&lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;alternative image&amp;quot;&lt;/span&gt;
/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;&lt;span class=&quot;hljs-name&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;Social Login&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;/&lt;span class=&quot;hljs-name&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;/&lt;span class=&quot;hljs-name&quot;&gt;Button&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Problem occurred&lt;/h3&gt;
&lt;p&gt;When rebuilding this code using maps in TypeScript, an error occurred.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Type &apos;string&apos; is not assignable to type &apos;&amp;quot;text&amp;quot; | &amp;quot;outlined&amp;quot; | &amp;quot;contained&amp;quot; | undefined&apos;.&amp;quot;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I was using the MUI and it was spitting out the error in the value of the variant property of the MUI Button. I struggled with this for a while and searched high and low through StackOverFlow and ChatGPT until I finally figured it out.&lt;/p&gt;
&lt;h3&gt;Solution.&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-typescript&quot;&gt;
&lt;span class=&quot;hljs-keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;Variant&lt;/span&gt; = &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;text&amp;quot;&lt;/span&gt; | &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;outlined&amp;quot;&lt;/span&gt; | &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;contained&amp;quot;&lt;/span&gt; | &lt;span class=&quot;hljs-literal&quot;&gt;undefined&lt;/span&gt;;

&lt;span class=&quot;hljs-keyword&quot;&gt;interface&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;SubmitButtonProps&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;ButtonProps&lt;/span&gt; {
  &lt;span class=&quot;hljs-attr&quot;&gt;variant&lt;/span&gt;?: &lt;span class=&quot;hljs-title class_&quot;&gt;Variant&lt;/span&gt;;
  &lt;span class=&quot;hljs-attr&quot;&gt;onClick&lt;/span&gt;?: &lt;span class=&quot;hljs-function&quot;&gt;() =&amp;gt;&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;Promise&lt;/span&gt;&amp;lt;&lt;span class=&quot;hljs-built_in&quot;&gt;void&lt;/span&gt;&amp;gt;;
  &lt;span class=&quot;hljs-attr&quot;&gt;contains&lt;/span&gt;?: &lt;span class=&quot;hljs-title class_&quot;&gt;React&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;ReactNode&lt;/span&gt;;
}

{loginButtonSettings.&lt;span class=&quot;hljs-title function_&quot;&gt;map&lt;/span&gt;(
  &lt;span class=&quot;hljs-function&quot;&gt;(&lt;span class=&quot;hljs-params&quot;&gt;{ onClick, contains, variant }: &lt;span class=&quot;hljs-title class_&quot;&gt;SubmitButtonProps&lt;/span&gt;, &lt;span class=&quot;hljs-attr&quot;&gt;index&lt;/span&gt;: &lt;span class=&quot;hljs-built_in&quot;&gt;number&lt;/span&gt;&lt;/span&gt;) =&amp;gt;&lt;/span&gt; (
    &lt;span class=&quot;language-xml&quot;&gt;&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;&lt;span class=&quot;hljs-name&quot;&gt;SubmitButton&lt;/span&gt;
    &lt;span class=&quot;hljs-attr&quot;&gt;key&lt;/span&gt;=&lt;span class=&quot;hljs-string&quot;&gt;{index}&lt;/span&gt;
  	&lt;span class=&quot;hljs-attr&quot;&gt;onClick&lt;/span&gt;=&lt;span class=&quot;hljs-string&quot;&gt;{onClick}&lt;/span&gt;
	&lt;span class=&quot;hljs-attr&quot;&gt;contains&lt;/span&gt;=&lt;span class=&quot;hljs-string&quot;&gt;{contains}&lt;/span&gt;
	&lt;span class=&quot;hljs-attr&quot;&gt;variant&lt;/span&gt;=&lt;span class=&quot;hljs-string&quot;&gt;{variant}&lt;/span&gt;
	/&amp;gt;&lt;/span&gt;&lt;/span&gt;
  )
)}

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As shown above, we need to predetermine the attribute values that will go into the variant through the value of type, and we also need to attach it to the interface. Actually, the next part is more important than this.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-typescript&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;const&lt;/span&gt; loginButtonSettings = [
  {
    &lt;span class=&quot;hljs-attr&quot;&gt;onClick&lt;/span&gt;: loginHandler,
    &lt;span class=&quot;hljs-attr&quot;&gt;contains&lt;/span&gt;: &lt;span class=&quot;language-xml&quot;&gt;&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;&lt;span class=&quot;hljs-name&quot;&gt;div&lt;/span&gt;&amp;gt;&lt;/span&gt;Login&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;/&lt;span class=&quot;hljs-name&quot;&gt;div&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;,
    &lt;span class=&quot;hljs-attr&quot;&gt;variant&lt;/span&gt;: &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;contained&amp;quot;&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;Variant&lt;/span&gt;, &lt;span class=&quot;hljs-comment&quot;&gt;// 바로 여기!&lt;/span&gt;
  },
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see, &amp;quot;contained&amp;quot; is generally recognized as a string, so we need to make sure that it is the value that was contained in the Variant property value!&lt;/p&gt;
</content:encoded></item><item><title>Entering Refactoring</title><link>https://www.traceoflight.dev/en/blog/refactoring/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/refactoring/</guid><description>A retrospective and why we use the Stack before diving into refactoring</description><pubDate>Tue, 21 Feb 2023 16:26:20 GMT</pubDate><content:encoded>&lt;h3&gt;Reason for recording&lt;/h3&gt;
&lt;p&gt;After about 7 weeks of short and long projects, I think I&apos;ve gotten to know React to a certain extent. But unlike I thought, I want to keep this friend nice and neat, but somehow it&apos;s like watching a beard that grows messy...&lt;/p&gt;
&lt;p&gt;So, I thought, &amp;quot;Let&apos;s fix that code!&amp;quot; and I&apos;m going to take this opportunity to try out TypeScript while keeping a record of my simple project.&lt;/p&gt;
&lt;h3&gt;Why React?&lt;/h3&gt;
&lt;p&gt;In the previous project I participated in, I had the opportunity to use VueJS, so I had experience writing code based on Vue, but I wasn&apos;t experienced enough to compare the pros and cons, and I hadn&apos;t even used React before, so I thought, &amp;quot;It&apos;s the hottest framework right now, so let&apos;s try it!&amp;quot;. I think it was an opportunity to realize the advantages of React rather than the disadvantages of Vue.&lt;/p&gt;
&lt;h4&gt;Ecosystem is wide&lt;/h4&gt;
&lt;p&gt;I think this is a well-known advantage, both numerically and otherwise, but most of the libraries I used in Vue are also available in React, and I felt that this is the main thing and Vue is a freebie.&lt;/p&gt;
&lt;h4&gt;Intuitive&lt;/h4&gt;
&lt;p&gt;I don&apos;t know if it&apos;s because I haven&apos;t used a lot of Hooks yet, but I felt much more comfortable with the way Props are handled and the way I write code.&lt;/p&gt;
&lt;p&gt;In the case of UE, I felt like I had to write templates, scripts, and styles like a head, chest, and stomach to make a sense of distinction between the code, but React basically writes the Function Component in a way that does not distinguish it from the JavaScript code, so I felt much more convenient in accessing variables, etc.&lt;/p&gt;
&lt;p&gt;Of course, if you separate them like Vue, it might be easier to read the code, but from a writing perspective, there was a clear difference, and even now, if I were to ask, &amp;quot;What should I use?&amp;quot; I would use React.&lt;/p&gt;
&lt;h4&gt;Event handling was convenient&lt;/h4&gt;
&lt;p&gt;This is somewhat shared with the above, but I remember that writing EventHandlers was much more intuitive than when I was using Vue. In the case of Vue, I think there were many parts that separated functions and variables, but React allows you to declare and process variables on the spot, just like using a general programming language, so it felt like a warm and comforting feeling like the vitiligo I used to eat every day.&lt;/p&gt;
&lt;h3&gt;Why do you want to use TypeScript?&lt;/h3&gt;
&lt;p&gt;Although the pros and cons of React may be different from the pros and cons of the actual industry, I was able to personally point out the above advantages of React and still chose React in the refactoring process.&lt;/p&gt;
&lt;p&gt;Similarly, I think it&apos;s good to write down the reasons why I want to use TS instead of JS when refactoring, so I&apos;ll leave it here.&lt;/p&gt;
&lt;h4&gt;Error Catching&lt;/h4&gt;
&lt;p&gt;I think a lot of the strengths of TS address the weaknesses of JS. Basically, I think JS is a very loose language, and it is, so there are times when errors occur in strange places and are difficult to solve, and I expect TS to catch them well.&lt;/p&gt;
&lt;h4&gt;Familiarity&lt;/h4&gt;
&lt;p&gt;JS has a lot of things that I personally don&apos;t like about it as a programming language due to its inevitable development history. However, TS is obviously based on JS, but it provides a very tight structure that solves what JS was lacking! Of course, it can be tweaked more, but the comfort that comes from the familiarity of a stable structure is what makes me use TS...&lt;/p&gt;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;I will continue to write about what I&apos;ve learned and compare it to my previous code in future posts. I don&apos;t know how long it will take, but I expect it to be a very rewarding process!&lt;/p&gt;
</content:encoded></item><item><title>[BOJ 1922, Java] Network Connection</title><link>https://www.traceoflight.dev/en/blog/boj1922/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/boj1922/</guid><description>Java Solution for BOJ Problem 1922, &amp;quot;Network Connection&amp;quot;</description><pubDate>Mon, 20 Feb 2023 07:55:51 GMT</pubDate><content:encoded>&lt;h3&gt;Problem Link&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/1922&quot;&gt;BOJ 1922&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Category&lt;/h3&gt;
&lt;p&gt;Graph Theory, Minimum Spanning Tree&lt;/p&gt;
&lt;h3&gt;Description&lt;/h3&gt;
&lt;h4&gt;Introduction&lt;/h4&gt;
&lt;p&gt;Lately, I’ve been focusing solely on solving problems, which has made me feel like I’ve been neglecting the theory. So, I’d like to document my problem-solving process while briefly reviewing the theory.&lt;/p&gt;
&lt;h4&gt;MST (Minimum Spanning Tree)&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;What is a spanning tree?&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;A spanning tree is a tree that contains every vertex in a graph.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Minimum Spanning Tree (MST)&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;: The spanning tree with the shortest total edge length.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Key Features&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;: It has (n - 1) edges passing through n vertices.
: Since it minimizes edge length, it can be used for building internal networks, etc.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4&gt;Prim’s Algorithm&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Select one initial vertex&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Sequentially select the shortest edge among those connected to vertices included in the MST&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Terminate when all vertices are connected&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Kruskal&apos;s Algorithm&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Sort all edges by weight&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Sequentially add edges while ensuring no cycles are formed&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Terminate when all vertices are connected&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Solution Code&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-java&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; java.io.*;
&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; java.util.*;

&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;Main&lt;/span&gt; {

    &lt;span class=&quot;hljs-comment&quot;&gt;// 간선 정보 클래스 선언&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;Connection&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;implements&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;Comparable&lt;/span&gt;&amp;lt;Connection&amp;gt; {

        &lt;span class=&quot;hljs-keyword&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;final&lt;/span&gt; &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; cost;
        &lt;span class=&quot;hljs-keyword&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;final&lt;/span&gt; &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; start;
        &lt;span class=&quot;hljs-keyword&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;final&lt;/span&gt; &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; end;

        &lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;Connection&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; cost, &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; start, &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; end)&lt;/span&gt; {
            &lt;span class=&quot;hljs-built_in&quot;&gt;this&lt;/span&gt;.cost = cost;
            &lt;span class=&quot;hljs-built_in&quot;&gt;this&lt;/span&gt;.start = start;
            &lt;span class=&quot;hljs-built_in&quot;&gt;this&lt;/span&gt;.end = end;
        }

        &lt;span class=&quot;hljs-comment&quot;&gt;// 가중치를 통한 비교&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;compareTo&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(Connection other)&lt;/span&gt; {
            &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;this&lt;/span&gt;.cost - other.cost;
        }

    }

    &lt;span class=&quot;hljs-comment&quot;&gt;// 정점의 집합을 확인하는 함수&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;checkUnion&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;[] unionInfo, &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; targetVertex)&lt;/span&gt; {

        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (unionInfo[targetVertex] != targetVertex) {
            unionInfo[targetVertex] = checkUnion(unionInfo, unionInfo[targetVertex]);
        }

        &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; unionInfo[targetVertex];
    }

    &lt;span class=&quot;hljs-comment&quot;&gt;// 정점 2개가 집합을 이루는지 확인하는 함수&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;hljs-type&quot;&gt;boolean&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;isUnion&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;[] unionInfo, &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; vertex1, &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; vertex2)&lt;/span&gt; {
        &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; checkUnion(unionInfo, vertex1) == checkUnion(unionInfo, vertex2);
    }

    &lt;span class=&quot;hljs-comment&quot;&gt;// 집합을 합쳐주는 함수&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;makeUnion&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;[] unionInfo, &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; vertex1, &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; vertex2)&lt;/span&gt; {

        &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;group1&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; checkUnion(unionInfo, vertex1);
        &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;group2&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; checkUnion(unionInfo, vertex2);

        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (group2 &amp;gt; group1) {
            unionInfo[group2] = group1;
        } &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt; {
            unionInfo[group1] = group2;
        }

    }

    &lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(String[] args)&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;throws&lt;/span&gt; IOException {

        &lt;span class=&quot;hljs-type&quot;&gt;BufferedReader&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;input&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;BufferedReader&lt;/span&gt;(&lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;InputStreamReader&lt;/span&gt;(System.in));
        &lt;span class=&quot;hljs-type&quot;&gt;BufferedWriter&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;output&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;BufferedWriter&lt;/span&gt;(&lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;OutputStreamWriter&lt;/span&gt;(System.out));

        &lt;span class=&quot;hljs-comment&quot;&gt;// 정점 및 간선의 갯수 입력&lt;/span&gt;
        &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;vertexNumber&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; Integer.parseInt(input.readLine());
        &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;edgeNumber&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; Integer.parseInt(input.readLine());

        &lt;span class=&quot;hljs-comment&quot;&gt;// 간선 정보를 담을 우선순위 큐 선언&lt;/span&gt;
        PriorityQueue&amp;lt;Connection&amp;gt; costPriorityQueue = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;PriorityQueue&lt;/span&gt;&amp;lt;&amp;gt;();

        &lt;span class=&quot;hljs-comment&quot;&gt;// 간선 정보 입력&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; i &amp;lt; edgeNumber; i++) {
            &lt;span class=&quot;hljs-type&quot;&gt;StringTokenizer&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;connectionInfo&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;StringTokenizer&lt;/span&gt;(input.readLine(), &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;[ ]&amp;quot;&lt;/span&gt;);

            &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;startNode&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; Integer.parseInt(connectionInfo.nextToken());
            &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;endNode&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; Integer.parseInt(connectionInfo.nextToken());
            &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;cost&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; Integer.parseInt(connectionInfo.nextToken());

            &lt;span class=&quot;hljs-type&quot;&gt;Connection&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;connection&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;Connection&lt;/span&gt;(cost, startNode, endNode);
            costPriorityQueue.add(connection);

        }

        &lt;span class=&quot;hljs-comment&quot;&gt;// 집합에 포함된 정점의 갯수와 최소 가중치 정보를 담을 변수 선언&lt;/span&gt;
        &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;totalCost&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;;
        &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;totalEdge&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;;

        &lt;span class=&quot;hljs-comment&quot;&gt;// 집합 정보를 담을 배열 선언&lt;/span&gt;
        &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;[] groupInfo = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;int&lt;/span&gt;[vertexNumber + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;];
        &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; i &amp;lt; vertexNumber + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;; i++) {
            groupInfo[i] = i;
        }

        &lt;span class=&quot;hljs-comment&quot;&gt;// Kruskal&amp;#x27;s Algorithm&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;while&lt;/span&gt; (totalEdge &amp;lt; vertexNumber - &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt; &amp;amp;&amp;amp; !costPriorityQueue.isEmpty()) {

            &lt;span class=&quot;hljs-comment&quot;&gt;// 가중치 순으로 확인&lt;/span&gt;
            &lt;span class=&quot;hljs-type&quot;&gt;Connection&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;nowConnection&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; costPriorityQueue.poll();

            &lt;span class=&quot;hljs-comment&quot;&gt;// 집합 관계를 확인하여 아직 집합이 아닌 경우 집합에 추가하고 가중치 가산&lt;/span&gt;
            &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (!isUnion(groupInfo, nowConnection.start, nowConnection.end)) {
                makeUnion(groupInfo, nowConnection.start, nowConnection.end);
                totalEdge += &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;;
                totalCost += nowConnection.cost;
            }

        }

        &lt;span class=&quot;hljs-comment&quot;&gt;// 최종 최소 가중치값 출력&lt;/span&gt;
        output.write(Integer.toString(totalCost));

        output.flush();
        output.close();

    }

}

&lt;/code&gt;&lt;/pre&gt;
</content:encoded></item><item><title>[BOJ 14503, Java] Robot Vacuum Cleaner</title><link>https://www.traceoflight.dev/en/blog/boj14503/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/boj14503/</guid><description>Java Solution to BOJ 14503, &quot;Robot Vacuum Cleaner&quot; Problem</description><pubDate>Sat, 18 Feb 2023 12:31:09 GMT</pubDate><content:encoded>&lt;h3&gt;Problem link&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;@@tlp1@@&quot;&gt;boj 14503&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Classification&lt;/h3&gt;
&lt;p&gt;implementation, simulation, simulation&lt;/p&gt;
&lt;h3&gt;Description&lt;/h3&gt;
&lt;p&gt;This is a typical implementation problem, but the description of the problem is a little tricky to understand. I&apos;ll try to comment only on that part.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;clean the current cell&lt;/li&gt;
&lt;li&gt;check the direction from the current slot &lt;strong&gt;(counterclockwise 90 degrees)&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;go all the way around to where you were looking at the beginning and back up if there is nothing to clean.&lt;/li&gt;
&lt;li&gt;if there is nothing left to clean, end cleaning&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If you overlook the part of the problem that checks the left side of the face first, you will get confused about the implementation. Be careful when solving this problem!&lt;/p&gt;
&lt;h3&gt;Solving code&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-java&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; java.io.*;
&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; java.util.*;

&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;Main&lt;/span&gt; {

    &lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; height;
    &lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; width;

    &lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;hljs-type&quot;&gt;boolean&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;isNeedClean&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;[][] table, &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; nowYIndex, &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; nowXIndex)&lt;/span&gt; {
        &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; table[nowYIndex][nowXIndex] == &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;;
    }

    &lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(String[] args)&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;throws&lt;/span&gt; IOException {

        &lt;span class=&quot;hljs-type&quot;&gt;BufferedReader&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;input&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;BufferedReader&lt;/span&gt;(&lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;InputStreamReader&lt;/span&gt;(System.in));
        &lt;span class=&quot;hljs-type&quot;&gt;BufferedWriter&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;output&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;BufferedWriter&lt;/span&gt;(&lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;OutputStreamWriter&lt;/span&gt;(System.out));

        &lt;span class=&quot;hljs-type&quot;&gt;StringTokenizer&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;mapSize&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;StringTokenizer&lt;/span&gt;(input.readLine(), &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;[ ]&amp;quot;&lt;/span&gt;);

        &lt;span class=&quot;hljs-comment&quot;&gt;// 뒷 방향 등록 해시맵 선언&lt;/span&gt;
        HashMap&amp;lt;Integer, Integer&amp;gt; backward = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;HashMap&lt;/span&gt;&amp;lt;&amp;gt;();
        backward.put(&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;);
        backward.put(&lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;);
        backward.put(&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;3&lt;/span&gt;);
        backward.put(&lt;span class=&quot;hljs-number&quot;&gt;3&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;);

        height = Integer.parseInt(mapSize.nextToken());
        width = Integer.parseInt(mapSize.nextToken());

        &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;[][] mapInfo = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;int&lt;/span&gt;[height][width];

        &lt;span class=&quot;hljs-type&quot;&gt;StringTokenizer&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;startingPoint&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;StringTokenizer&lt;/span&gt;(input.readLine(), &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;[ ]&amp;quot;&lt;/span&gt;);

        &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;nowY&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; Integer.parseInt(startingPoint.nextToken());
        &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;nowX&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; Integer.parseInt(startingPoint.nextToken());
        &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;nowDirection&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; Integer.parseInt(startingPoint.nextToken());

        &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; i &amp;lt; height; i++) {
            &lt;span class=&quot;hljs-type&quot;&gt;StringTokenizer&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;mapLine&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;StringTokenizer&lt;/span&gt;(input.readLine(), &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;[ ]&amp;quot;&lt;/span&gt;);

            &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;j&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; j &amp;lt; width; j++) {
                mapInfo[i][j] = Integer.parseInt(mapLine.nextToken());
            }

        }

        &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;cleanCounter&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;;

        &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;[] directionY = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;int&lt;/span&gt;[]{-&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;};
        &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;[] directionX = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;int&lt;/span&gt;[]{&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, -&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;};

        Loop:
        &lt;span class=&quot;hljs-keyword&quot;&gt;while&lt;/span&gt; (&lt;span class=&quot;hljs-literal&quot;&gt;true&lt;/span&gt;) {

            &lt;span class=&quot;hljs-comment&quot;&gt;// 현재 칸이 청소가 필요하다면 청소 실시&lt;/span&gt;
            &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (isNeedClean(mapInfo, nowY, nowX)) {
                mapInfo[nowY][nowX] = &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;;
                cleanCounter += &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;;
            }

            &lt;span class=&quot;hljs-comment&quot;&gt;// 주변 칸에 대해서 확인&lt;/span&gt;
            &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;; i &amp;lt; &lt;span class=&quot;hljs-number&quot;&gt;5&lt;/span&gt;; i++) {

                &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;targetDirection&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; (nowDirection + &lt;span class=&quot;hljs-number&quot;&gt;4&lt;/span&gt; - i) % &lt;span class=&quot;hljs-number&quot;&gt;4&lt;/span&gt;;
                &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;targetY&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; nowY + directionY[targetDirection];
                &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;targetX&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; nowX + directionX[targetDirection];

                &lt;span class=&quot;hljs-comment&quot;&gt;// 청소할 칸이 있는 경우 이동 및 방향 전환&lt;/span&gt;
                &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (isNeedClean(mapInfo, targetY, targetX)) {
                    nowY = targetY;
                    nowX = targetX;
                    nowDirection = targetDirection;
                    &lt;span class=&quot;hljs-keyword&quot;&gt;break&lt;/span&gt;;
                }

                &lt;span class=&quot;hljs-comment&quot;&gt;// 청소할 칸이 없는 경우 뒷칸 확인&lt;/span&gt;
                &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (i == &lt;span class=&quot;hljs-number&quot;&gt;4&lt;/span&gt;) {
                    targetY = nowY + directionY[backward.get(nowDirection)];
                    targetX = nowX + directionX[backward.get(nowDirection)];

                    &lt;span class=&quot;hljs-comment&quot;&gt;// 뒤로 이동할 수 없는 경우 청소 종료&lt;/span&gt;
                    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (mapInfo[targetY][targetX] == &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;) {
                        &lt;span class=&quot;hljs-keyword&quot;&gt;break&lt;/span&gt; Loop;

                        &lt;span class=&quot;hljs-comment&quot;&gt;// 이동할 수 있다면 뒤로 1칸 후진&lt;/span&gt;
                    } &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt; {
                        nowY = targetY;
                        nowX = targetX;
                    }
                }

            }

        }

        &lt;span class=&quot;hljs-comment&quot;&gt;// 이동 결과 출력&lt;/span&gt;
        output.write(Integer.toString(cleanCounter));

        output.flush();
        output.close();

    }

}
&lt;/code&gt;&lt;/pre&gt;
</content:encoded></item><item><title>First interview reviews</title><link>https://www.traceoflight.dev/en/blog/first-interview/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/first-interview/</guid><description>A brief review of the first interview</description><pubDate>Tue, 07 Feb 2023 11:30:12 GMT</pubDate><content:encoded>&lt;blockquote&gt;
&lt;p&gt;2023-07-06 Thumbnail Edit (&lt;a href=&quot;https://kr.freepik.com/free-vector/interview-concept-illustration_7446777.htm#from_view=detail_alsolike&quot;&gt;author storyset&lt;/a&gt; from Freepik)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;It&apos;s been a while since I&apos;ve written anything.&lt;/p&gt;
&lt;p&gt;I&apos;m currently completing my 8th SSAFY course, so I haven&apos;t had as much time to write as I thought I would.&lt;/p&gt;
&lt;p&gt;However, after going through an important process such as an interview, I don&apos;t think it would be helpful for my development if I don&apos;t organize these things, so I write this article hastily.&lt;/p&gt;
&lt;h3&gt;Interview process&lt;/h3&gt;
&lt;p&gt;It was a video interview, and I expected it to be more of a personality interview than a technical interview, but as expected, it was not a technical interview.&lt;/p&gt;
&lt;p&gt;I&apos;m not sure if I should be glad that I anticipated and prepared for this, or if I should be disappointed that I lost the opportunity to gain experience...&lt;/p&gt;
&lt;p&gt;As for the interview questions, off the top of my head, I&apos;d say they were&lt;/p&gt;
&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;1 minute introductions every time&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Why did you choose your current field as opposed to your major? (I&apos;m a non-major)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;About the gap&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The work environment is this and that, but it may not be what you thought it would be, is that okay?&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;p&gt;I wrote a little abstractly, but I was glad that I was able to respond with what I had prepared. Especially for non-majors, there are always questions that are aimed at their lack of CS knowledge compared to majors, so you need to be prepared to some extent!&lt;/p&gt;
&lt;h3&gt;Personal reflections&lt;/h3&gt;
&lt;p&gt;However, since it was not a technical interview, I think it was more disappointing that there were not many questions about it, as I don&apos;t know when I will pass the next coding test.&lt;/p&gt;
&lt;p&gt;I&apos;ve heard that the interview is as much a time for the interviewer to re-estimate the company as it is for the company to judge the interviewee, and I think I felt that in this interview.&lt;/p&gt;
&lt;p&gt;In the case of the company I interviewed with this time, I think I will be doing something very different from the job I was thinking of, so I wonder if I will have a lot of trouble even if I get the job...!&lt;/p&gt;
</content:encoded></item><item><title>[BOJ 16934, Java] Game Nickname</title><link>https://www.traceoflight.dev/en/blog/boj16934/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/boj16934/</guid><description>Java Solution for BOJ Problem 16934, &amp;quot;Game Nickname&amp;quot;</description><pubDate>Wed, 28 Dec 2022 00:35:18 GMT</pubDate><content:encoded>&lt;h3&gt;Problem Link&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/16934&quot;&gt;BOJ 16934&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Categories&lt;/h3&gt;
&lt;p&gt;Data Structures, Sets and Maps Using Hashes, Strings, Trees, Tries&lt;/p&gt;
&lt;h3&gt;Description&lt;/h3&gt;
&lt;p&gt;Personally, I feel I’m not very good at string problems and think I need to study a bit harder, but this problem could be solved using the trie algorithm.&lt;/p&gt;
&lt;p&gt;There were plenty of test cases, so checking for counterexamples wasn’t difficult, but if the examples hadn’t been so clean, this problem would have been a real headache...&lt;/p&gt;
&lt;p&gt;Since I hadn’t implemented tree-based structures in Java before, it took me a bit of time, but let’s take pride in the fact that I implemented it without any outside help!&lt;/p&gt;
&lt;h3&gt;Solution Code&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-java&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; java.io.*;
&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; java.util.*;

&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;Main&lt;/span&gt; {

    &lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;Node&lt;/span&gt; {

        &lt;span class=&quot;hljs-type&quot;&gt;char&lt;/span&gt; nowChar;
        String value;
        &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;count&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;;
        &lt;span class=&quot;hljs-type&quot;&gt;boolean&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;isUnique&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-literal&quot;&gt;true&lt;/span&gt;;
        HashSet&amp;lt;Node&amp;gt; childSet;

        &lt;span class=&quot;hljs-comment&quot;&gt;// 헤드에 사용하기 위한 정의 방식&lt;/span&gt;
        Node() {

            &lt;span class=&quot;hljs-built_in&quot;&gt;this&lt;/span&gt;.childSet = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;HashSet&lt;/span&gt;&amp;lt;&amp;gt;();
            &lt;span class=&quot;hljs-built_in&quot;&gt;this&lt;/span&gt;.value = &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;;
            &lt;span class=&quot;hljs-built_in&quot;&gt;this&lt;/span&gt;.isUnique = &lt;span class=&quot;hljs-literal&quot;&gt;false&lt;/span&gt;;

        }

        &lt;span class=&quot;hljs-comment&quot;&gt;// 일반적인 서브노드들을 위한 정의 방식&lt;/span&gt;
        Node(&lt;span class=&quot;hljs-type&quot;&gt;char&lt;/span&gt; target) {

            &lt;span class=&quot;hljs-built_in&quot;&gt;this&lt;/span&gt;.nowChar = target;
            &lt;span class=&quot;hljs-built_in&quot;&gt;this&lt;/span&gt;.childSet = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;HashSet&lt;/span&gt;&amp;lt;&amp;gt;();
            &lt;span class=&quot;hljs-built_in&quot;&gt;this&lt;/span&gt;.value = &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;;

        }

    }

    &lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;Trie&lt;/span&gt; {

        &lt;span class=&quot;hljs-comment&quot;&gt;// 헤드 노드 1개를 보유하고 시작&lt;/span&gt;
        &lt;span class=&quot;hljs-type&quot;&gt;Node&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;head&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;Node&lt;/span&gt;();

        &lt;span class=&quot;hljs-comment&quot;&gt;/**
         * 문자열 1개를 트라이 클래스에 추가하는 메서드
         */&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;addString&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(String target)&lt;/span&gt; {

            &lt;span class=&quot;hljs-type&quot;&gt;Node&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;nowNode&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;this&lt;/span&gt;.head;
            &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;targetLength&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; target.length();

            &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; i &amp;lt;= targetLength; i++) {

                &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (i == targetLength) {

                    nowNode.count += &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;;
                    nowNode.value = target;

                } &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt; {

                    &lt;span class=&quot;hljs-type&quot;&gt;boolean&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;hasChild&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-literal&quot;&gt;false&lt;/span&gt;;

                    &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (Node subNode : nowNode.childSet) {

                        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (subNode.nowChar == target.charAt(i)) {

                            nowNode = subNode;
                            hasChild = &lt;span class=&quot;hljs-literal&quot;&gt;true&lt;/span&gt;;
                            &lt;span class=&quot;hljs-keyword&quot;&gt;break&lt;/span&gt;;

                        }

                    }

                    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (!hasChild) {

                        &lt;span class=&quot;hljs-type&quot;&gt;Node&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;madeNode&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;Node&lt;/span&gt;(target.charAt(i));
                        nowNode.childSet.add(madeNode);
                        nowNode = madeNode;

                    }

                }

            }

        }

        &lt;span class=&quot;hljs-comment&quot;&gt;/**
         * 문자열의 고유 별칭을 찾아내는 메서드
         */&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; String &lt;span class=&quot;hljs-title function_&quot;&gt;findUnique&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(String target)&lt;/span&gt; {

            &lt;span class=&quot;hljs-type&quot;&gt;Node&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;nowNode&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;this&lt;/span&gt;.head;
            &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;targetLength&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; target.length();
            &lt;span class=&quot;hljs-type&quot;&gt;boolean&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;isFirstTime&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-literal&quot;&gt;true&lt;/span&gt;;
            &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; -&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;;
            &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;resultCount&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; -&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;;

            &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; i &amp;lt; targetLength + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;; i++) {

                &lt;span class=&quot;hljs-comment&quot;&gt;// 첫 번째로 만나는 고유값이 해당 문자열의 별칭&lt;/span&gt;
                &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (nowNode.isUnique &amp;amp;&amp;amp; isFirstTime) {

                    nowNode.isUnique = &lt;span class=&quot;hljs-literal&quot;&gt;false&lt;/span&gt;;
                    isFirstTime = &lt;span class=&quot;hljs-literal&quot;&gt;false&lt;/span&gt;;
                    result = i;
                    resultCount = nowNode.count;

                    &lt;span class=&quot;hljs-comment&quot;&gt;// 이후로도 만나는 고유값은 고유값이 아니도록 처리&lt;/span&gt;
                } &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt; {

                    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (nowNode.isUnique) {
                        nowNode.isUnique = &lt;span class=&quot;hljs-literal&quot;&gt;false&lt;/span&gt;;
                    }

                }

                &lt;span class=&quot;hljs-comment&quot;&gt;// 마지막 문자까지 확인&lt;/span&gt;
                &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (i == targetLength) {

                    &lt;span class=&quot;hljs-comment&quot;&gt;// 마지막 문자까지 고유값을 체크하지 못한 경우&lt;/span&gt;
                    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (result == -&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;) {
                        result = targetLength;
                        resultCount = nowNode.count;
                    }

                    &lt;span class=&quot;hljs-comment&quot;&gt;// 카운팅 갯수에 따른 값을 반환&lt;/span&gt;
                    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (nowNode.count == &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;) {
                        &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; target.substring(&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, result);

                    } &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt; {
                        &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; target + resultCount;
                    }

                    &lt;span class=&quot;hljs-comment&quot;&gt;// 마지막 문자 이전까지는 트라이 내 탐색 방식으로 진행&lt;/span&gt;
                } &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt; {

                    &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (Node subNode : nowNode.childSet) {

                        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (subNode.nowChar == target.charAt(i)) {
                            nowNode = subNode;
                            &lt;span class=&quot;hljs-keyword&quot;&gt;break&lt;/span&gt;;

                        }

                    }

                }

            }

            &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;ERROR!&amp;quot;&lt;/span&gt;;

        }

    }

    &lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(String[] args)&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;throws&lt;/span&gt; IOException {

        &lt;span class=&quot;hljs-type&quot;&gt;BufferedReader&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;input&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;BufferedReader&lt;/span&gt;(&lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;InputStreamReader&lt;/span&gt;(System.in));
        &lt;span class=&quot;hljs-type&quot;&gt;BufferedWriter&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;output&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;BufferedWriter&lt;/span&gt;(&lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;OutputStreamWriter&lt;/span&gt;(System.out));

        &lt;span class=&quot;hljs-comment&quot;&gt;// Trie Algorithm&lt;/span&gt;

        &lt;span class=&quot;hljs-comment&quot;&gt;// 트라이 인스턴스 선언&lt;/span&gt;
        &lt;span class=&quot;hljs-type&quot;&gt;Trie&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;nickNameTrie&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;Trie&lt;/span&gt;();

        &lt;span class=&quot;hljs-comment&quot;&gt;// 유저 수 입력&lt;/span&gt;
        &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;userNumber&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; Integer.parseInt(input.readLine());

        &lt;span class=&quot;hljs-comment&quot;&gt;// 모든 유저에 대해 진행&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; i &amp;lt; userNumber; i++) {

            &lt;span class=&quot;hljs-comment&quot;&gt;// 닉네임 입력 및 트라이에 추가&lt;/span&gt;
            &lt;span class=&quot;hljs-type&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;nickName&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; input.readLine();
            nickNameTrie.addString(nickName);

            &lt;span class=&quot;hljs-comment&quot;&gt;// 함수를 호출하여 해당 닉네임에 대한 별칭 출력&lt;/span&gt;
            &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (i == userNumber - &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;) {
                output.write(nickNameTrie.findUnique(nickName));

            } &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt; {
                output.write(nickNameTrie.findUnique(nickName) + &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;\n&amp;quot;&lt;/span&gt;);
            }

        }

        output.flush();
        output.close();

    }

}

&lt;/code&gt;&lt;/pre&gt;
</content:encoded></item><item><title>[BOJ 17114, Java] Hyper Tomato</title><link>https://www.traceoflight.dev/en/blog/boj17114/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/boj17114/</guid><description>Java Solution for BOJ Problem 17114, &amp;quot;Hyper Tomato&amp;quot;</description><pubDate>Thu, 22 Dec 2022 04:36:35 GMT</pubDate><content:encoded>&lt;h3&gt;Problem Link&lt;/h3&gt;
&lt;p&gt;[BOJ 17114] (&amp;lt;&lt;a href=&quot;https://www.acmicpc.net/problem/17114&amp;amp;gt;&quot;&gt;https://www.acmicpc.net/problem/17114&amp;amp;gt;&lt;/a&gt;)&lt;/p&gt;
&lt;h3&gt;Categories&lt;/h3&gt;
&lt;p&gt;Implementation, Graph Theory, Graph Traversal, Breadth-First Search (BFS)&lt;/p&gt;
&lt;h3&gt;Description&lt;/h3&gt;
&lt;p&gt;Personally, I think this problem really demonstrates just how messy BFS can get.&lt;/p&gt;
&lt;p&gt;I’ve known about this problem for a while, and even though the solution itself is well-known and famous, I’ve learned once again that implementing my own solution is a different challenge altogether.&lt;/p&gt;
&lt;p&gt;Fast I/O is a given, and if you don’t trim the fat when performing breadth-first search, you’re likely to get a timeout.&lt;/p&gt;
&lt;p&gt;I’m not sure if you can solve this using &lt;code&gt;sys.stdin.readline&lt;/code&gt; in Python, but fortunately, in Java, I was able to handle it using &lt;code&gt;BufferedReader&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;After solving this problem and doing some research, it seems there are smarter ways to solve it, but here I solved it by brutally extending the classic BFS.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Input coordinate information into an 11-dimensional array&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Count unripe tomatoes; record the coordinates of ripe tomatoes&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Iterate through ripe tomatoes, adding adjacent unripe tomatoes to the list of ripe tomatoes while decrementing the count; repeat this process based on the conditions&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If the count reaches 0, all tomatoes are ripe, so output the number of days taken&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If the count does not reach 0, but the number of unripe tomatoes does not change when repeating step (3) on the existing unripe tomatoes, it means they can no longer ripen, so output -1.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;When solving this problem, if you handle steps 2 and 3 differently—&lt;strong&gt;that is, if you increment the counter every iteration or fail to remove the coordinates of ripe tomatoes that have already been used—you may receive a timeout...&lt;/strong&gt; I struggled with this for quite a while before finally solving it.&lt;/p&gt;
&lt;h3&gt;Solution Code&lt;/h3&gt;
&lt;p&gt;The code is quite long... but I think it’s unavoidable given the use of 11 nested for loops and the need to represent adjacent coordinates.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-java&quot;&gt;
&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; java.io.*;
&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; java.util.*;

&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;Main&lt;/span&gt; {

    &lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; tomatoLeft;

    &lt;span class=&quot;hljs-comment&quot;&gt;/**
     * 토마토가 익는 메커니즘을 반영하여 1일 뒤의 배열로 변경하는 함수
     */&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;ripeTomato&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;[][][][][][][][][][][] target, Queue&amp;lt;&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;[]&amp;gt; tomatoQueue, &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;[] sizeInfo)&lt;/span&gt; {

        &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;[][] movements = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;int&lt;/span&gt;[][]{
                &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;int&lt;/span&gt;[]{&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;},
                &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;int&lt;/span&gt;[]{-&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;},
                &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;int&lt;/span&gt;[]{&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;},
                &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;int&lt;/span&gt;[]{&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, -&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;},
                &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;int&lt;/span&gt;[]{&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;},
                &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;int&lt;/span&gt;[]{&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, -&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;},
                &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;int&lt;/span&gt;[]{&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;},
                &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;int&lt;/span&gt;[]{&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, -&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;},
                &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;int&lt;/span&gt;[]{&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;},
                &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;int&lt;/span&gt;[]{&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, -&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;},
                &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;int&lt;/span&gt;[]{&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;},
                &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;int&lt;/span&gt;[]{&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, -&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;},
                &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;int&lt;/span&gt;[]{&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;},
                &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;int&lt;/span&gt;[]{&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, -&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;},
                &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;int&lt;/span&gt;[]{&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;},
                &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;int&lt;/span&gt;[]{&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, -&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;},
                &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;int&lt;/span&gt;[]{&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;},
                &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;int&lt;/span&gt;[]{&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, -&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;},
                &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;int&lt;/span&gt;[]{&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;},
                &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;int&lt;/span&gt;[]{&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, -&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;},
                &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;int&lt;/span&gt;[]{&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;},
                &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;int&lt;/span&gt;[]{&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, -&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;},
        };

        ArrayList&amp;lt;&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;[]&amp;gt; ripeList = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;ArrayList&lt;/span&gt;&amp;lt;&amp;gt;();

        &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;[] nowIdx : tomatoQueue) {

            &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;[] movement : movements) {

                &lt;span class=&quot;hljs-type&quot;&gt;boolean&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;isNotOverIndex&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-literal&quot;&gt;true&lt;/span&gt;;

                &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; i &amp;lt; &lt;span class=&quot;hljs-number&quot;&gt;11&lt;/span&gt;; i++) {
                    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt; &amp;gt; nowIdx[i] + movement[i] || nowIdx[i] + movement[i] &amp;gt;= sizeInfo[i]) {
                        isNotOverIndex = &lt;span class=&quot;hljs-literal&quot;&gt;false&lt;/span&gt;;
                        &lt;span class=&quot;hljs-keyword&quot;&gt;break&lt;/span&gt;;
                    }
                }

                &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;nextIdx00&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; nowIdx[&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;] + movement[&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;];
                &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;nextIdx01&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; nowIdx[&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;] + movement[&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;];
                &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;nextIdx02&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; nowIdx[&lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;] + movement[&lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;];
                &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;nextIdx03&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; nowIdx[&lt;span class=&quot;hljs-number&quot;&gt;3&lt;/span&gt;] + movement[&lt;span class=&quot;hljs-number&quot;&gt;3&lt;/span&gt;];
                &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;nextIdx04&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; nowIdx[&lt;span class=&quot;hljs-number&quot;&gt;4&lt;/span&gt;] + movement[&lt;span class=&quot;hljs-number&quot;&gt;4&lt;/span&gt;];
                &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;nextIdx05&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; nowIdx[&lt;span class=&quot;hljs-number&quot;&gt;5&lt;/span&gt;] + movement[&lt;span class=&quot;hljs-number&quot;&gt;5&lt;/span&gt;];
                &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;nextIdx06&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; nowIdx[&lt;span class=&quot;hljs-number&quot;&gt;6&lt;/span&gt;] + movement[&lt;span class=&quot;hljs-number&quot;&gt;6&lt;/span&gt;];
                &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;nextIdx07&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; nowIdx[&lt;span class=&quot;hljs-number&quot;&gt;7&lt;/span&gt;] + movement[&lt;span class=&quot;hljs-number&quot;&gt;7&lt;/span&gt;];
                &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;nextIdx08&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; nowIdx[&lt;span class=&quot;hljs-number&quot;&gt;8&lt;/span&gt;] + movement[&lt;span class=&quot;hljs-number&quot;&gt;8&lt;/span&gt;];
                &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;nextIdx09&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; nowIdx[&lt;span class=&quot;hljs-number&quot;&gt;9&lt;/span&gt;] + movement[&lt;span class=&quot;hljs-number&quot;&gt;9&lt;/span&gt;];
                &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;nextIdx10&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; nowIdx[&lt;span class=&quot;hljs-number&quot;&gt;10&lt;/span&gt;] + movement[&lt;span class=&quot;hljs-number&quot;&gt;10&lt;/span&gt;];

                &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (

                        isNotOverIndex

                                &amp;amp;&amp;amp; target[nextIdx00][nextIdx01][nextIdx02]
                                [nextIdx03][nextIdx04][nextIdx05][nextIdx06]
                                [nextIdx07][nextIdx08][nextIdx09][nextIdx10]
                                == &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;

                ) {

                    ripeList.add(

                            &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;int&lt;/span&gt;[]{
                                    nextIdx00, nextIdx01, nextIdx02,
                                    nextIdx03, nextIdx04, nextIdx05, nextIdx06,
                                    nextIdx07, nextIdx08, nextIdx09, nextIdx10
                            }

                    );

                }

            }

        }

        tomatoQueue.clear();

        &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;[] ripeCoord : ripeList) {

            &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (

                    target[ripeCoord[&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;]][ripeCoord[&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;]][ripeCoord[&lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;]]
                            [ripeCoord[&lt;span class=&quot;hljs-number&quot;&gt;3&lt;/span&gt;]][ripeCoord[&lt;span class=&quot;hljs-number&quot;&gt;4&lt;/span&gt;]][ripeCoord[&lt;span class=&quot;hljs-number&quot;&gt;5&lt;/span&gt;]][ripeCoord[&lt;span class=&quot;hljs-number&quot;&gt;6&lt;/span&gt;]]
                            [ripeCoord[&lt;span class=&quot;hljs-number&quot;&gt;7&lt;/span&gt;]][ripeCoord[&lt;span class=&quot;hljs-number&quot;&gt;8&lt;/span&gt;]][ripeCoord[&lt;span class=&quot;hljs-number&quot;&gt;9&lt;/span&gt;]][ripeCoord[&lt;span class=&quot;hljs-number&quot;&gt;10&lt;/span&gt;]] == &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;

            ) {

                target[ripeCoord[&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;]][ripeCoord[&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;]][ripeCoord[&lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;]]
                        [ripeCoord[&lt;span class=&quot;hljs-number&quot;&gt;3&lt;/span&gt;]][ripeCoord[&lt;span class=&quot;hljs-number&quot;&gt;4&lt;/span&gt;]][ripeCoord[&lt;span class=&quot;hljs-number&quot;&gt;5&lt;/span&gt;]][ripeCoord[&lt;span class=&quot;hljs-number&quot;&gt;6&lt;/span&gt;]]
                        [ripeCoord[&lt;span class=&quot;hljs-number&quot;&gt;7&lt;/span&gt;]][ripeCoord[&lt;span class=&quot;hljs-number&quot;&gt;8&lt;/span&gt;]][ripeCoord[&lt;span class=&quot;hljs-number&quot;&gt;9&lt;/span&gt;]][ripeCoord[&lt;span class=&quot;hljs-number&quot;&gt;10&lt;/span&gt;]] = &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;;

                tomatoLeft -= &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;;

                tomatoQueue.add(ripeCoord);

            }

        }

    }

    &lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(String[] args)&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;throws&lt;/span&gt; IOException {

        &lt;span class=&quot;hljs-type&quot;&gt;BufferedReader&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;input&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;BufferedReader&lt;/span&gt;(&lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;InputStreamReader&lt;/span&gt;(System.in));
        &lt;span class=&quot;hljs-type&quot;&gt;BufferedWriter&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;output&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;BufferedWriter&lt;/span&gt;(&lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;OutputStreamWriter&lt;/span&gt;(System.out));

        &lt;span class=&quot;hljs-comment&quot;&gt;// 배열 사이즈 입력&lt;/span&gt;
        &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;[] storageSize = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;int&lt;/span&gt;[&lt;span class=&quot;hljs-number&quot;&gt;11&lt;/span&gt;];
        &lt;span class=&quot;hljs-type&quot;&gt;StringTokenizer&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;sizeInput&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;StringTokenizer&lt;/span&gt;(input.readLine(), &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;[ ]&amp;quot;&lt;/span&gt;);

        &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; i &amp;lt; &lt;span class=&quot;hljs-number&quot;&gt;11&lt;/span&gt;; i++) {
            storageSize[i] = Integer.parseInt(sizeInput.nextToken());
        }

        &lt;span class=&quot;hljs-comment&quot;&gt;// 창고 정보 입력&lt;/span&gt;
        &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;[][][][][][][][][][][] tomatoStorage = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;int&lt;/span&gt;[storageSize[&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;]][storageSize[&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;]][storageSize[&lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;]]
                [storageSize[&lt;span class=&quot;hljs-number&quot;&gt;3&lt;/span&gt;]][storageSize[&lt;span class=&quot;hljs-number&quot;&gt;4&lt;/span&gt;]][storageSize[&lt;span class=&quot;hljs-number&quot;&gt;5&lt;/span&gt;]][storageSize[&lt;span class=&quot;hljs-number&quot;&gt;6&lt;/span&gt;]]
                [storageSize[&lt;span class=&quot;hljs-number&quot;&gt;7&lt;/span&gt;]][storageSize[&lt;span class=&quot;hljs-number&quot;&gt;8&lt;/span&gt;]][storageSize[&lt;span class=&quot;hljs-number&quot;&gt;9&lt;/span&gt;]][storageSize[&lt;span class=&quot;hljs-number&quot;&gt;10&lt;/span&gt;]];

        Queue&amp;lt;&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt;[]&amp;gt; ripeTomatoQueue = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;LinkedList&lt;/span&gt;&amp;lt;&amp;gt;();

        &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;idx10&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; idx10 &amp;lt; storageSize[&lt;span class=&quot;hljs-number&quot;&gt;10&lt;/span&gt;]; idx10++) {
            &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;idx09&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; idx09 &amp;lt; storageSize[&lt;span class=&quot;hljs-number&quot;&gt;9&lt;/span&gt;]; idx09++) {
                &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;idx08&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; idx08 &amp;lt; storageSize[&lt;span class=&quot;hljs-number&quot;&gt;8&lt;/span&gt;]; idx08++) {
                    &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;idx07&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; idx07 &amp;lt; storageSize[&lt;span class=&quot;hljs-number&quot;&gt;7&lt;/span&gt;]; idx07++) {
                        &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;idx06&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; idx06 &amp;lt; storageSize[&lt;span class=&quot;hljs-number&quot;&gt;6&lt;/span&gt;]; idx06++) {
                            &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;idx05&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; idx05 &amp;lt; storageSize[&lt;span class=&quot;hljs-number&quot;&gt;5&lt;/span&gt;]; idx05++) {
                                &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;idx04&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; idx04 &amp;lt; storageSize[&lt;span class=&quot;hljs-number&quot;&gt;4&lt;/span&gt;]; idx04++) {
                                    &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;idx03&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; idx03 &amp;lt; storageSize[&lt;span class=&quot;hljs-number&quot;&gt;3&lt;/span&gt;]; idx03++) {
                                        &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;idx02&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; idx02 &amp;lt; storageSize[&lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;]; idx02++) {
                                            &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;idx01&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; idx01 &amp;lt; storageSize[&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;]; idx01++) {

                                                &lt;span class=&quot;hljs-type&quot;&gt;StringTokenizer&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;storageInfo&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;StringTokenizer&lt;/span&gt;(input.readLine(), &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;[ ]&amp;quot;&lt;/span&gt;);

                                                &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;idx00Counter&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; idx00Counter &amp;lt; storageSize[&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;]; idx00Counter++) {

                                                    &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;nowInput&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; Integer.parseInt(storageInfo.nextToken());

                                                    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (nowInput == &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;) {

                                                        ripeTomatoQueue.add(
                                                                &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;int&lt;/span&gt;[]{
                                                                        idx00Counter, idx01, idx02,
                                                                        idx03, idx04, idx05, idx06,
                                                                        idx07, idx08, idx09, idx10
                                                                }
                                                        );

                                                    } &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (nowInput == &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;) {

                                                        tomatoLeft += &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;;

                                                    }

                                                    tomatoStorage[idx00Counter][idx01][idx02]
                                                            [idx03][idx04][idx05][idx06]
                                                            [idx07][idx08][idx09][idx10]
                                                            = nowInput;

                                                }

                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

        &lt;span class=&quot;hljs-comment&quot;&gt;// 지난 날짜 카운팅 변수 및 모두 익지 못하는 상황을 체크하기 위한 Flag 선언&lt;/span&gt;
        &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;dayCounter&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;;
        &lt;span class=&quot;hljs-type&quot;&gt;boolean&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;cantComplete&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-literal&quot;&gt;false&lt;/span&gt;;

        &lt;span class=&quot;hljs-comment&quot;&gt;// 모두 익지 않았다면 반복&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;while&lt;/span&gt; (tomatoLeft &amp;gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;) {

            &lt;span class=&quot;hljs-comment&quot;&gt;// 함수를 호출하여 기존 배열 깊은 복사 후 1일 뒤의 배열 확인&lt;/span&gt;
            &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;lastTomato&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; tomatoLeft;
            ripeTomato(tomatoStorage, ripeTomatoQueue, storageSize);

            &lt;span class=&quot;hljs-comment&quot;&gt;// 날짜 1 카운트&lt;/span&gt;
            dayCounter += &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;;

            &lt;span class=&quot;hljs-comment&quot;&gt;// 아직 다 익지 않았지만 기존이랑 차이가 없다면 전부 익을 수 없는 상황이므로 Flag 변경 후 break&lt;/span&gt;
            &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (tomatoLeft != &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt; &amp;amp;&amp;amp; tomatoLeft == lastTomato) {
                cantComplete = &lt;span class=&quot;hljs-literal&quot;&gt;true&lt;/span&gt;;
                &lt;span class=&quot;hljs-keyword&quot;&gt;break&lt;/span&gt;;
            }

        }

        &lt;span class=&quot;hljs-comment&quot;&gt;// 문제 조건에 따라서 출력&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (cantComplete) {
            output.write(&lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;-1&amp;quot;&lt;/span&gt;);
        } &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt; {
            output.write(Integer.toString(dayCounter));
        }

        output.flush();
        output.close();

    }

}

&lt;/code&gt;&lt;/pre&gt;
</content:encoded></item><item><title>[BOJ 3865, Java] Society Member</title><link>https://www.traceoflight.dev/en/blog/boj3865/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/boj3865/</guid><description>Java Solution for BOJ 3865, &amp;quot;Society Members&amp;quot;</description><pubDate>Mon, 12 Dec 2022 13:50:33 GMT</pubDate><content:encoded>&lt;h3&gt;Problem Link&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/3865&quot;&gt;BOJ 3865&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Categories&lt;/h3&gt;
&lt;p&gt;Breadth-First Search (BFS), Data Structures, Depth-First Search (DFS), Graph Theory, Graph Traversal, Sets and Maps Using Hashes, Parsing, Strings(string)&lt;/p&gt;
&lt;h3&gt;Description&lt;/h3&gt;
&lt;p&gt;It seems that string-related problems have been appearing frequently in recent coding tests, so I came across this problem while looking for string-related challenges.&lt;/p&gt;
&lt;p&gt;Since it involved depth-first search, I was familiar with the approach. Although I’m still not fully proficient in Java, so it took me a bit of time to solve it, the overall solution stayed within the framework of depth-first search.&lt;/p&gt;
&lt;p&gt;It was a problem that could be solved by properly processing the string data, continuously checking the set of visit records for the conference and student names, and using recursion combined with counting for each case where a visit hadn’t yet occurred.&lt;/p&gt;
&lt;h3&gt;Solution Code&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-java&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; java.io.*;
&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; java.util.*;

&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;Main&lt;/span&gt; {

    &lt;span class=&quot;hljs-comment&quot;&gt;/**
     * 해당 학회의 총 인원수를 반환하는 함수
     */&lt;/span&gt;

    &lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;getTotalPerson&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(String target)&lt;/span&gt; {

        &lt;span class=&quot;hljs-comment&quot;&gt;// 결과값 변수 선언&lt;/span&gt;
        &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;;

        &lt;span class=&quot;hljs-comment&quot;&gt;// 아직 방문하지 않은 경우에 대해서만 처리&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (!visitLog.contains(target)) {

            &lt;span class=&quot;hljs-comment&quot;&gt;// 방문 기록&lt;/span&gt;
            visitLog.add(target);

            &lt;span class=&quot;hljs-comment&quot;&gt;// 사람이 아닌 학회일 경우&lt;/span&gt;
            &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (clubGraph.containsKey(target)) {

                &lt;span class=&quot;hljs-comment&quot;&gt;// 해당 학회의 방문하지 않은 구성원에 대해 재귀함수를 호출, 결과값에 합산&lt;/span&gt;
                &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (String eachPerson : clubGraph.get(target)) {

                    &lt;span class=&quot;hljs-comment&quot;&gt;// 구성원이 학회라면 재귀함수 호출&lt;/span&gt;
                    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (clubGraph.containsKey(eachPerson)) {
                        result += getTotalPerson(eachPerson);

                    &lt;span class=&quot;hljs-comment&quot;&gt;// 학생이라면 아직 방문하지 않았을 경우 결과값 1 추가&lt;/span&gt;
                    } &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt; {

                        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (!visitLog.contains(eachPerson)) {

                            visitLog.add(eachPerson);
                            result += &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;;

                        }

                    }

                }

            }

        }

        &lt;span class=&quot;hljs-comment&quot;&gt;// 결과값을 반환&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; result;

    }

    &lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;strToInt&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(String inputString)&lt;/span&gt; {
        &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; Integer.parseInt(inputString);
    }

    &lt;span class=&quot;hljs-comment&quot;&gt;// 학회 수, 첫 학회, 학회 관계 그래프, 학생 기록 집합 정적 변수 선언&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; clubNumber;
    &lt;span class=&quot;hljs-keyword&quot;&gt;static&lt;/span&gt; String firstClub;
    &lt;span class=&quot;hljs-keyword&quot;&gt;static&lt;/span&gt; HashMap&amp;lt;String, ArrayList&amp;lt;String&amp;gt;&amp;gt; clubGraph = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;HashMap&lt;/span&gt;&amp;lt;&amp;gt;();
    &lt;span class=&quot;hljs-keyword&quot;&gt;static&lt;/span&gt; Set&amp;lt;String&amp;gt; visitLog = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;HashSet&lt;/span&gt;&amp;lt;&amp;gt;();

    &lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(String[] args)&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;throws&lt;/span&gt; IOException {

        &lt;span class=&quot;hljs-type&quot;&gt;BufferedReader&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;input&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;BufferedReader&lt;/span&gt;(&lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;InputStreamReader&lt;/span&gt;(System.in));

        &lt;span class=&quot;hljs-comment&quot;&gt;// 학회의 수 입력, 입력값이 0이라면 반복 종료&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;while&lt;/span&gt; ((clubNumber = strToInt(input.readLine())) != &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;) {

            clubGraph.clear();
            visitLog.clear();

            &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-type&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; i &amp;lt; clubNumber; i++) {

                &lt;span class=&quot;hljs-comment&quot;&gt;// 줄 단위 입력&lt;/span&gt;
                &lt;span class=&quot;hljs-type&quot;&gt;StringTokenizer&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;clubInfo&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;StringTokenizer&lt;/span&gt;(input.readLine(),&lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;[:,.]&amp;quot;&lt;/span&gt;);

                &lt;span class=&quot;hljs-comment&quot;&gt;// 학회 이름 변수 선언&lt;/span&gt;
                &lt;span class=&quot;hljs-type&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;clubName&lt;/span&gt; &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; clubInfo.nextToken();

                &lt;span class=&quot;hljs-comment&quot;&gt;// 첫 학회라면 따로 변수에 기록&lt;/span&gt;
                &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (i == &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;) {
                    firstClub = clubName;
                }

                &lt;span class=&quot;hljs-comment&quot;&gt;// 기존에 없던 학회라면 추가&lt;/span&gt;
                &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (!clubGraph.containsKey(clubName)) {
                    clubGraph.put(clubName, &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;ArrayList&lt;/span&gt;&amp;lt;&amp;gt;());
                }

                &lt;span class=&quot;hljs-comment&quot;&gt;// 나머지를 전부 학회의 원소로 추가&lt;/span&gt;
                &lt;span class=&quot;hljs-keyword&quot;&gt;while&lt;/span&gt; (clubInfo.hasMoreTokens()) {
                    clubGraph.get(clubName).add(clubInfo.nextToken());
                }

            }

            &lt;span class=&quot;hljs-comment&quot;&gt;// 함수를 호출하여 결과값을 출력 스택에 추가&lt;/span&gt;
            System.out.println(getTotalPerson(firstClub));

        }

    }

}
&lt;/code&gt;&lt;/pre&gt;
</content:encoded></item><item><title>SQLD Exam Pass Review and Study Materials</title><link>https://www.traceoflight.dev/en/blog/sqld/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/sqld/</guid><description>SQLD Certification Success Story</description><pubDate>Tue, 29 Nov 2022 15:32:31 GMT</pubDate><content:encoded>&lt;p&gt;&lt;span class=&quot;md-media-frame media-load-frame&quot; data-media-shell&gt;&lt;img src=&quot;/media/image/imported-0d43c36638e8bf56-image.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; data-md-fallback data-media-load&gt;&lt;span class=&quot;md-media-fallback md-image-fallback&quot; hidden&gt;이미지를 불러올 수 없습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I passed the 47th SQL Developer Certification Exam. Since this is the first certification I’ve earned after completely changing my career path, I feel a great sense of pride.&lt;/p&gt;
&lt;p&gt;At first, I wanted to dedicate about a month to it, but I ended up wasting quite a bit of time—either getting swamped with other tasks or approaching it too theoretically—so I do have some regrets. I’m leaving a record here of the points I confirmed while studying.&lt;/p&gt;
&lt;p&gt;The final section contains concepts I organized personally, and since there are practical details or edits I made to help me memorize them scattered throughout, there may be some parts that don’t quite match up! Still, since this might help someone, I’m leaving the entire content as is and plan to edit it later if I think of anything.&lt;/p&gt;
&lt;h1&gt;Time Spent and Study Method&lt;/h1&gt;
&lt;p&gt;I actually spent about two weeks on this, with about one week dedicated to solving practice problems.&lt;/p&gt;
&lt;p&gt;At first, I wanted to study using the concept explanations provided by [Data on Air](&lt;a href=&quot;https://dataonair.or.kr/&quot;&gt;https://dataonair.or.kr/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;) as a standard approach, but I gave up on that early on after realizing that the SQLD exam itself features far more questions based on practical SQL syntax than on theoretical concepts. However, I still think the content itself is good, so I recommend checking it out if you have the time!&lt;/p&gt;
&lt;p&gt;Next, I got a general overview by watching various types of lectures on YouTube. Since there are quite a few well-organized lectures specifically for the SQLD exam, it should be sufficient to just pick the ones that look promising.&lt;/p&gt;
&lt;p&gt;Finally, there’s the practice problems. For these, there are resources available on related forums or blogs that have compiled past exam questions. While the book commonly known as the “Yellow Book” is good, it’s important not to neglect the solutions to past exam questions! For the Yellow Book, I only read through the first two chapters once and organized my error log; I spent the rest of my time entirely on solving past exam questions.&lt;/p&gt;
&lt;p&gt;The website I personally recommend for a collection of reconstructed past exam questions is [this blog](&lt;a href=&quot;https://yunamom.tistory.com/category/%EC%9E%90%EA%B2%A9%EC%A6%9D/SQLD%20%EA%B8%B0%EC%B6%9C%EB%AC%B8%EC%A0%9C&quot;&gt;https://yunamom.tistory.com/category/자격증/SQLD 기출문제&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;). This is because you can immediately check whether your answer is correct simply by entering it.&lt;/p&gt;
&lt;h1&gt;Concept Review&lt;/h1&gt;
&lt;p&gt;Note: Since Chapter 1 has fewer practice problems than Chapter 2, it was prioritized lower; consequently, only the necessary content is included here, so the coverage may not be exhaustive.&lt;/p&gt;
&lt;h2&gt;Chapter 1&lt;/h2&gt;
&lt;h2&gt;Classification of Entities&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Basic / Key Entities&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Central Entities&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Activity Entities&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Data Modeling&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A business analysis technique from a data perspective for building information systems&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Representing real-world data using agreed-upon notation&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The analysis and design process for building a database&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Points to Note When Performing Data Modeling&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Redundancy&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Inflexibility&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Inconsistency&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Types of Data Modeling&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Conceptual: High level of abstraction; comprehensive and business-centric approach&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Logical: Accurately represents keys, attributes, and relationships; designed for high reusability&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Physical: Designed to be portable to an actual database and takes physical characteristics into account&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Structure of a Database Schema&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;External&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Conceptual&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Internal&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Steps for Creating an ERD&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Draw the entities.&lt;/li&gt;
&lt;li&gt;Arrange the entities appropriately.&lt;/li&gt;
&lt;li&gt;Define the relationships between entities.&lt;/li&gt;
&lt;li&gt;Label the relationship names.&lt;/li&gt;
&lt;li&gt;Specify the degree of participation in the relationship.&lt;/li&gt;
&lt;li&gt;Indicate whether the relationship is mandatory.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Characteristics of an Entity&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Information required and managed within the specific business process&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Must be a unique identifier.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Has two or more instances.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Must be used in practice.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Must have attributes.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Must form at least one relationship.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;1개 엔터티: 2개 이상의 인스턴스 집합 + 2개 이상의 속성
1개 속성: 1개 이상의 속성값
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Classification of Attributes by Characteristics&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Basic Attributes&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Design Attributes&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Derived Attributes&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Domain&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The range of values each attribute can take&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Specifies the data type, size, and constraints for attributes within an entity&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Naming Attributes&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Names must be those used in the relevant business context.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Do not use descriptive attribute names.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Avoid using abbreviations.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Ensure uniqueness across the entire data model.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;ERDs do not distinguish between ontological and behavioral relationships.
However, Class Diagrams do make this distinction and must describe association and dependency relationships.&lt;/p&gt;
&lt;h2&gt;Relationship Notation&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Relationship Name: The name of the relationship&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Relationship Degree: 1:1, 1:M, M:N&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Relationship Specification: Required, Optional&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Reading Relationships&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Read the reference entity as &amp;quot;One&amp;quot; or &amp;quot;Each.&amp;quot;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Read the relationship participation of the target entity.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Read the relationship specifier and relationship name.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Types of Identifiers&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Representativeness: Primary Identifier vs. Secondary Identifier&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Self-Generation: Internal vs. External&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Single-Attribute Identification: Single vs. Composite&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Semantic Significance: Natural vs. Artificial&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Characteristics of Primary Keys&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Uniqueness&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Rarity&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Immutability&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Existence&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Performance Data Modeling&lt;/h2&gt;
&lt;p&gt;Reflecting performance-related considerations in data modeling to improve database performance&lt;/p&gt;
&lt;h2&gt;Targets of First Normal Form&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Separation of redundant attributes&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Row-level redundancy&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Column-level redundancy&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Denormalization&lt;/h2&gt;
&lt;p&gt;By duplicating, consolidating, or separating normalized entities, attributes, and relationships,
system performance is improved, and development and operations are simplified.
This is performed when performance degradation is expected, even if it may compromise data integrity.&lt;/p&gt;
&lt;h3&gt;Procedure&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Identify targets for denormalization&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Frequency of range processing&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Massive range processing&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Statistical processes&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Number of table joins&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If alternative methods are available, consider redirecting to those methods&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Use view tables when there are many joins&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Use clustering when processing large volumes of data&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Split data using partitioning when holding large volumes of data&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Index maintenance&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Modify application logic&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Super/Subtype Data Model Transformation Techniques&lt;/h2&gt;
&lt;p&gt;Individual Transactions -&amp;gt; Individual Tables
Super + Sub-types -&amp;gt; Super + Sub-tables
Entire Data Set -&amp;gt; Single Table&lt;/p&gt;
&lt;h2&gt;Criteria for Determining Primary Key Order&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Specify to enable efficient use of indexes&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The value of the attribute located at the beginning should serve as the comparison operator&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Preferably use &apos;=&apos;, BETWEEN, or &apos;&amp;lt;&amp;gt;&apos;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Advantages and Disadvantages of Distributed Databases&lt;/h2&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h3&gt;Advantages&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Local autonomy; enables gradual system capacity expansion&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Reliability and availability / Efficiency and flexibility&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Fast response times, reduced communication costs, and better accommodation of local user needs&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Increased data availability and reliability; scalability of system size&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Disadvantages&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Increased development costs and potential for errors, higher processing costs, and threats to data integrity&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Difficulties in the design process, administrative complexity and costs, inconsistent response times, and difficulty in control&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Chapter 2&lt;/h2&gt;
&lt;h2&gt;Types of SQL Statements&lt;/h2&gt;
&lt;h3&gt;DCL&lt;/h3&gt;
&lt;p&gt;Data Control Language, commands for managing permissions&lt;/p&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;GRANT&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Used to grant permissions&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Used in the form: ``GRANT {permission} ON {table} TO {user};`&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;(e.g.,&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;```text
WITH GRANT, WITH ADMIN의 비교

GRANT: 특정 사용자에게 권한 부여가 가능한 권한을 부여, 부여한 부모의 권한이 회수될 때 자식의 권한도 회수
ADMIN: 테이블에 대한 모든 권한을 부여, 부여한 부모의 권한 회수와 관계 없는 권한
```
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`)&lt;br /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;REVOKE&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Used to revoke permissions&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Used in the form: ``REVOKE {permission} ON {table} FROM {user};`&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;`&lt;/p&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h4&gt;Types of Permissions:&lt;/h4&gt;
&lt;pre&gt;&lt;code class=&quot;language-sql&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;ALL&lt;/span&gt; &lt;span class=&quot;hljs-comment&quot;&gt;-- 모든 권한 부여&lt;/span&gt;
&lt;span class=&quot;hljs-keyword&quot;&gt;SELECT&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;INSERT&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;UPDATE&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;DELETE&lt;/span&gt; &lt;span class=&quot;hljs-comment&quot;&gt;/*  */&lt;/span&gt;
&lt;span class=&quot;hljs-keyword&quot;&gt;REFERENCES&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;ALTER&lt;/span&gt; INDEX &lt;span class=&quot;hljs-comment&quot;&gt;/*  */&lt;/span&gt;

&lt;span class=&quot;hljs-comment&quot;&gt;/* ROLE: 다양한 권한을 하나의 그룹으로 묶어서 관리 */&lt;/span&gt;
&lt;span class=&quot;hljs-keyword&quot;&gt;CREATE&lt;/span&gt; ROLE {role_name}; &lt;span class=&quot;hljs-comment&quot;&gt;-- 권한 그룹 생성&lt;/span&gt;
&lt;span class=&quot;hljs-keyword&quot;&gt;GRANT&lt;/span&gt; {permission_type} &lt;span class=&quot;hljs-keyword&quot;&gt;TO&lt;/span&gt; {role_name}; &lt;span class=&quot;hljs-comment&quot;&gt;-- 해당 그룹에 권한 등록&lt;/span&gt;
&lt;span class=&quot;hljs-keyword&quot;&gt;GRANT&lt;/span&gt; {role_name} &lt;span class=&quot;hljs-keyword&quot;&gt;TO&lt;/span&gt; {user_1}, {user_2}...; &lt;span class=&quot;hljs-comment&quot;&gt;-- 다른 유저들에게 권한 그룹 부여&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;DDL&lt;/h3&gt;
&lt;p&gt;Data Definition Language: Commands that define data&lt;/p&gt;
&lt;p&gt;Supports Auto Commit in SQL Server&lt;/p&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;CREATE&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Creates table structure&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Used in the form: ``CREATE TABLE {table_name} {table_elements};`&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;`&lt;br /&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;```sql
CREATE TABLE EXAMPLE (
/* 
  컬럼명은 영어, 한글, 숫자 전부 가능 
  첫 글자를 문자로 지정해야 하며, 컬럼의 데이터 타입은 반드시 설정해야 한다.
*/
		NAME  varchar2(max_length)  -- 최대 길이를 가진 가변길이 문자열
  	ID번호 char(length)          -- 고정된 길이 문자열
		나이_2 number(max_length)    -- 숫자형 데이터 타입
  	생일   date                  -- 날짜형 데이터 타입
);
```
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;code&gt;##### CONSTRAINT (Conditions)

* default: Specifies a default value

* not null: Prevents null values

* primary key: Specifies a primary key (not null, unique, multiple allowed)

* foreign key: Specifies a foreign key (multiple allowed)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h4&gt;ALTER&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Used to modify the structure of tables and columns, including changing, adding, or deleting names and properties&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Used in the form ``ALTER TABLE {table_name} {detail_order} {detail_property(if need)} TO {change_target};`&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;`&lt;br /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;code&gt;#### Detailed Commands

* RENAME: Renames a table or column

* MODIFY: Changes a column&amp;amp;#x27;s properties

* ADD: Adds a column

* DROP: Removes a column

* ADD CONSTRAINT / DROP CONSTRAINT: Adds or removes constraints
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;RENAME&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Allows you to change the names of tables and columns without using ALTER&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Allows you to change multiple table names simultaneously&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;DROP&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Allows you to remove tables and columns without using ALTER&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#### TABLE {table_name} CASCADE CONSTRAINT

* An option unique to Oracle; it does not exist in SQL Server

* For foreign key constraints, the referenced table is dropped first, followed by the dropping table.

* All foreign key constraints referencing the data in the dropped table are also removed
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;TRUNCATE&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Initializes the table (not a delete!)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Only the internal data is removed; the table’s existence and columns remain.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#### DROP vs TRUNCATE vs DELETE

* DROP: Removes the entire table and releases memory

* TRUNCATE: The table and columns remain, but memory is released for the remaining data

* DELETE: Removes records; a log of the data remains, allowing for rollback until the change is applied; no memory is released
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;DML&lt;/h3&gt;
&lt;p&gt;Data Manipulation Language, commands for manipulating records&lt;/p&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;INSERT&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Inserts data into records&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Used in the form ``INSERT INTO {table_name} {column_name} VALUES {change_column_name};`&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;`&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You can insert data without specifying column names, but if you do not specify them, all values must be provided.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;UPDATE&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Modifies existing data&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Used in the form: ``UPDATE {table_name} SET {column_name} = {column_value} WHERE {condition};`&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;`&lt;br /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;DELETE&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Removes existing data&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Used in the form: ``DELETE FROM {table_name} WHERE {condition};`&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;`&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;FROM&lt;/code&gt; can be omitted&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h4&gt;SELECT&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Retrieves specific data&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Used in the form: ``SELECT {select_target} FROM {select_origin} WHERE {condition};`&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;`&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Conditions can also be added in the form: ``GROUP BY {calc_type} HAVING {condition} / ORDER BY {sort_condition}`&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;`&lt;br /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;code&gt;#### DISTINCT

Condition to retrieve data without duplicates: (a, b, NULL, a, b, NULL) =&amp;amp;gt; (a, b, NULL)
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;COUNT&lt;/h4&gt;
&lt;pre&gt;&lt;code&gt;(\*): Counts the total number of rows, including NULL values

({column_name}): Counts the number of rows in a specific column, excluding NULL values
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;TCL&lt;/h3&gt;
&lt;p&gt;Transaction Control Language, transaction control commands&lt;/p&gt;
&lt;p&gt;Transaction: An operation that changes the state of the database&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;* transaction의 특징
고립성: 실행되는 동안 다른 transaction에 영향을 받아 잘못된 결과를 만들면 안됨
일관성: 실행 전 데이터베이스에 잘못된 점이 없다면 transaction 수행 후에도 내용에 오류가 있으면 안됨
지속성: transaction이 갱신한 데이터베이스 내용은 영구적으로 저장
원자성: transaction에서 정의한 연산은 모두 성공적으로 실행되거나 전혀 실행되지 않음 (All or Nothing)
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;COMMIT&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Applies changes to the data in the database&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;SAVEPOINT&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Specify a savepoint to serve as a branching point for code segmentation&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Used in the form: ``SAVEPOINT {savepoint_name};`&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;`&lt;br /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;ROLLBACK&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Command to revert to a previous state&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Can roll back to a savepoint or the most recent COMMIT&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Used in the form: ``ROLLBACK TO {rollback_point};`&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;`&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If no savepoint exists, the system reverts to the most recent COMMIT&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Benefits of TCL&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Ensures data integrity&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Allows verification of data changes before making permanent modifications&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Enables grouping and processing of logically related tasks&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Functions&lt;/h2&gt;
&lt;h3&gt;String Functions&lt;/h3&gt;
&lt;p&gt;Frequently used when specifying conditions such as SELECT and WHERE&lt;/p&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;LOWER&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Converts an English string to lowercase&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;UPPER&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Converts an English string to uppercase&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h4&gt;CONCAT&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Concatenates two strings&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Equivalent to Oracle&apos;s &apos;||&apos; and SQL Server&apos;s &apos;+&apos;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;SUBSTR&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Removes characters from the Mth position, leaving N characters&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;LENGTH, LEN&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Returns the length of a string, including spaces&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h4&gt;TRIM, LTRIM, RTRIM&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Removes all specified characters from both ends; if no characters are specified, removes spaces&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Numeric Functions&lt;/h3&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;ROUND&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Rounds&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;TRUNC&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Truncates&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h4&gt;CEIL&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The smallest integer greater than or equal to the number&lt;br /&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;FLOOR&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;The largest integer less than or equal to the number&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;MOD&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Modulo operation&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;SIGN&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Returns 1 for positive numbers, 0 for zero, and -1 for negative numbers&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h4&gt;ABS&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Absolute value&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Date Functions&lt;/h3&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;SYSDATE&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Returns the current date and time when the query is executed&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h4&gt;EXTRACT&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Used in the format ``EXTRACT ({information} FROM {data})`&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;`&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;How to extract desired values from date data&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Data Type Conversion&lt;/h3&gt;
&lt;p&gt;You can change data types using these functions&lt;/p&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;TO_NUMBER&lt;/h4&gt;
&lt;p&gt;String &amp;gt; Number&lt;/p&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;TO_CHAR&lt;/h4&gt;
&lt;p&gt;Number, Date &amp;gt; String (Generated differently depending on the format)&lt;/p&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;TO_DATE&lt;/h4&gt;
&lt;p&gt;String &amp;gt; Date (Generated differently depending on the format)&lt;/p&gt;
&lt;h3&gt;Basic Structure&lt;/h3&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;DECODE&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;IF statement&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;When conditions are simple&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;CASE WHEN&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Extended IF statement&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;When conditions require a lengthy list&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h4&gt;ORDER BY&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Sorting the retrieved table&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Multiple criteria can be used&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h4&gt;WHERE&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;IN, NOT IN: The condition is satisfied if the value matches or does not match any of the values in the list&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;IS NULL, IS NOT NULL: Determines whether the value is NULL or not, returning T / F&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;BETWEEN a AND b: Checks if a value exists between a and b and returns T/F (including a and b)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Comparison operators: =, &amp;gt;, &amp;lt;, &amp;gt;=, &amp;lt;=, etc.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A LIKE B: Finds a string similar to b for a&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;%: Indicates the presence of one or more characters&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;_: Represents a single character&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;명시적 형변환 vs 암시적 형변환

명시적 형변환: 함수를 활용하여 데이터 타입을 변경
암시적 형변환: 데이터베이스가 알아서 바꿔주는 것
&amp;gt;&amp;gt; 숫자 타입의 PK는 암묵적으로 인덱스가 되는데 데이터의 조회 등으로 암시적 형변환이 발생한 경우, 인덱스로 사용이 불가능
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;WITH&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Can be used like a temporary table or view by using a subquery&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Aliases can be specified&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Treated as an inline view or temporary table&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Used in the form ``WITH {table_name} AS {table_condition}`&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;`&lt;br /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;GROUP BY&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A command that performs grouping based on conditions&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Different combinations of values result in different groups&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;HAVING&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A conditional statement based on the state after grouping&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Supports functions such as COUNT (count), SUM (sum), AVG (average), MAX (maximum), MIN (minimum), STDDEV (standard deviation), and VARIAN (variance)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Conditions such as DISTINCT (remove duplicates) and ALL (all) can be used&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;NULL Functions&lt;/h3&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;NVL, ISNULL&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Functions that replace NULL values with other values&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Cannot be used if the data types are different&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h4&gt;NVL2&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A function that returns different results depending on whether the value is NULL or not&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Returns the first parameter if the value is not NULL, and the second parameter if it is NULL&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;NULLIF&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Returns NULL if both parameters are the same; otherwise, returns the first parameter&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h4&gt;COALESCE&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Returns the first non-NULL value&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;GROUP functions&lt;/h3&gt;
&lt;p&gt;Column values used for grouping and aggregation are output as NULL&lt;/p&gt;
&lt;p&gt;The same results can be obtained using standard group functions&lt;/p&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;ROLLUP&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Displays subtotals and grand totals.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The result varies depending on the order of the function’s arguments, and it returns aggregated values in a hierarchical structure.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h4&gt;CUBE&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Generates a sum of arguments for every possible grouping&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;GROUPING SETS&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Allows aggregation by sets enclosed in parentheses&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h4&gt;GROUPING&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;A function that returns 1 if a subtotal or total is calculated, and 0 otherwise&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;JOIN&lt;/h3&gt;
&lt;p&gt;Generally refers to the combination of tables; similar to sets&lt;/p&gt;
&lt;p&gt;JOINs are possible between tables, between a join result and a table, and between join results&lt;/p&gt;
&lt;p&gt;Applicable when at least one common attribute exists between the two related tables&lt;/p&gt;
&lt;p&gt;There are ANSI-standard queries that explicitly specify JOINs and non-standard queries that do not.&lt;/p&gt;
&lt;p&gt;When JOINs are listed, they are processed two at a time; it is not possible to process all of them simultaneously&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Intersection&lt;/p&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h4&gt;INNER JOIN&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Non-standard notation, abbreviated as&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;JOINs the intersection of both tables&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h4&gt;LEFT JOIN&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;When using non-standard notation, place a (+) on the left&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Joins all rows from the left table with only the intersection from the right table&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h4&gt;RIGHT JOIN&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;When using non-standard notation, place a (+) on the right&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Joins all rows from the right table with only the intersection from the left table&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h4&gt;OUTER JOIN&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Since OUTER JOIN cannot be used with a (+) on both sides, you must use an ANSI-standard query.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Unlike UNION, it can be applied even if there is only one common attribute.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Union&lt;/p&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h4&gt;UNION (ALL)&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A join method applicable when the number of columns in the joined tables is the same and the attributes of each column are identical&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The total amount of data becomes Data1 + Data2.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;UNION ALL combines the data without removing duplicates&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Union&lt;/p&gt;
&lt;p&gt;Applicable when you want to examine only a single set by excluding the intersection&lt;/p&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h4&gt;MINUS (Oracle)&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;EXCEPT (SQL Server)&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Degree of matching between the joined entities&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;EQUI JOIN: Combines two relations using identical columns&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;non-EQUI JOIN: Combines two relations using columns that do not exactly match&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;ex) A.key &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;= B.key
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;CROSS JOIN&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;If a JOIN is performed without a key, a Cartesian product is generated for the two tables&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;5개의 행 * 3개의 행 = 15개의 행으로 조회
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;SELF JOIN&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A JOIN between two columns within the same table that have a relationship&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Since both the table name and column names match, the use of an ALIAS is mandatory&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Optimizer Join&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Selection of methods for performance optimization during the JOIN process; specified using hints&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Hierarchical Query&lt;/h3&gt;
&lt;p&gt;Performing a query on tree-structured data&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The starting point of the hierarchy is set using START WITH (ROOT NODE)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A node with no child nodes = LEAF NODE&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Hierarchical levels are denoted by LEVEL&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h4&gt;CONNECT BY&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Determines the direction of the hierarchical structure&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Child &amp;gt; Parent&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Parent &amp;gt; Child&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;##### CONNECT BY PRIOR a = b

* Hierarchical relationships occur between records where columns a and b are identical

* Records are reordered in the sequence b -&amp;amp;gt; a
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;SIBLINGS BY&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Determines the ordering of sibling nodes&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;WINDOW FUNCTIONS&lt;/h3&gt;
&lt;p&gt;Functions used to easily define relationships between records, in the form of `&lt;/p&gt;
&lt;p&gt;&lt;code&gt;SELECT WINDOW_FUNCTION {arguments} OVER {partition by column} {order_style} FROM {table};&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;`&lt;br /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;WINDOW_FUNCTION&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Window functions&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Aggregate functions within a group: COUNT, SUM, MIN, MAX, AVG, etc.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Ranking functions within a group&lt;/p&gt;
&lt;p&gt;Even when using rank functions, sorting is not performed automatically, so you must use the ORDER BY clause.&lt;/p&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h5&gt;RANK&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Assigns the same rank to records with the same rank&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Does not count records with the same rank as a single instance&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h5&gt;DENSE_RANK&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Assigns the same rank to records with the same rank&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Counts records with the same rank as a single record&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h5&gt;ROW_NUMBER&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;Assigns a unique rank to records with the same rank&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Functions related to ratios within a group&lt;/p&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h5&gt;PERCENT_RANK&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;Returns the percentile rank within a partition based on &amp;quot;order&amp;quot; rather than the value&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h5&gt;NTILE(n)&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;Returns the value obtained by dividing the total count into n equal parts per partition&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h5&gt;CUME_DIST&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Returns the cumulative percentage of records within the partition that are equal to or less than the current row&apos;s value&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Returns a value between 0 and 1 on the cumulative distribution&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Row Order Functions Within a Group&lt;/p&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h5&gt;FIRST_VALUE&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;Returns the first value within a partition&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h5&gt;LAST_VALUE&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;Returns the last value within a partition&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h5&gt;LAG(column_name, record_difference)&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;Retrieves the previous row&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h5&gt;LEAD(column_name, record_difference, value_if_null)&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Retrieves the next row.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;DEFAULT = 1&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;ARGUMENTS&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Arguments (column names, etc., the targets on which the function operates)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h4&gt;PARTITION BY&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Criteria for partitioning table records&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;ORDER BY&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Specifies the criteria for sorting records within the partitioned records or across the entire table&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h4&gt;WINDOWING&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Defines the range of records on which the function operates&lt;/p&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h5&gt;RANGE&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;Used when specifying a range&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h5&gt;BETWEEN a AND b&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;Applies from a to b&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h5&gt;UNBOUNDED PRECEDING&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;Start position = first row&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h5&gt;UNBOUNDED FOLLOWING&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;Starting position = last row&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h5&gt;CURRENT ROW&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;Starting position = current row&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Table Partitioning&lt;/h3&gt;
&lt;p&gt;Storing a large table by splitting it into multiple data files&lt;/p&gt;
&lt;p&gt;Stored in physically separate data files =&amp;gt; Improved performance and independent management&lt;/p&gt;
&lt;p&gt;Effectively narrows the scope of queries =&amp;gt; Improved performance&lt;/p&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;RANGE PARTITION&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;A method of storing data by partitioning based on value ranges&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;LIST PARTITION&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Partitioning based on specific values&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;HASH PARTITION&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;A method where the database management system uses its own hash function to partition and manage data&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Optimizer&lt;/h2&gt;
&lt;p&gt;Even for the same SQL statement, performance varies depending on how it is executed (performance metrics: execution time, resource usage, etc.)&lt;/p&gt;
&lt;p&gt;Therefore, it is necessary to analyze the SQL statement and create an execution plan based on certain criteria; this is where the optimizer is used.&lt;/p&gt;
&lt;p&gt;The optimizer can affect execution performance, but it does not change the result.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-test&quot;&gt;SQL문 작성 =&amp;gt; 파싱 (문법 검사, 구문 분석) =&amp;gt; 옵티마이저 (비용 기반 / 규칙 기반) =&amp;gt; 실행 계획 (PLAN_TABLE 저장) =&amp;gt; SQL 실행
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;h3&gt;Cost-Based&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;In the latest Oracle versions, the cost-based optimizer is used by default&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Calculates the total cost of executing the SQL statement using system and object statistics, then establishes the execution plan with the lowest cost&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Rule-Based&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Develops an execution plan based on 15 priority rules&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Generally, a scan based on ROWID has the highest priority&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;INDEX&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Sorted by index key =&amp;gt; Faster lookup&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Primary keys (PKs) are automatically indexed&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Multiple indexes can be created on a single table, and a single index can consist of multiple columns&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Created and sorted in descending order&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;It is not advisable to index attributes that change frequently&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;For secondary indexes, duplicate data can be inserted unless the index has a UNIQUE constraint.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A full table scan may be more efficient and cost-effective than an index scan&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Partitioned tables can have partition key indexes created for each partition; these are called global indexes&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;As the number of indexes increases, so does the amount of data, which can lead to slower insert, delete, and update speeds&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Indexes can be created on all data types&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Types of indexes include sequential indexes, bitmap indexes, composite indexes, clustered indexes, and hash indexes.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#### SCAN Methods&amp;lt;br /&amp;gt;



* 

  ##### Index Unique SCAN

  * Searches using the index key when the key values are unique

*&amp;lt;br /&amp;gt;



  ##### Index Unique SCAN

  * Scans the specified range using a WHERE clause

  * Depending on the range, it may return a single result or no results at all

*&amp;lt;br /&amp;gt;



  ##### Index Full SCAN

  * Scans the entire index from start to finish
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Types of Optimizer Joins&lt;/h3&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#### Nested Loop JOIN

* First queries the outer (driving) table to find the data to be joined, then joins it with the inner (driven) table

* Throughput is determined by the processing range of the driving table; therefore, it is necessary to find a driving table with a small size

* Both row-level and table-level processing occur sequentially

* It is important to find the optimal order

* Since random access occurs (when the driving table references the second table), random access must be minimized to reduce performance latency

* In cases where the driving table’s processing range is large or the random access range is extensive, this method may be less efficient than a Sort Merge Join

* &amp;amp;quot;Index required&amp;amp;quot;; advantageous with a unique index

* Useful for Online Transaction Processing (OLTP)

* Same format as nested loops; executed iteratively as many times as there are rows that satisfy the conditions of the leading table
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;*&lt;br /&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#### Sort Merge JOIN

* Sorts each of the two tables and merges them upon completion

* Performance slows down when data volume is large due to the sorting process

* Performance degrades when a large amount of data is sorted because temporary disk space is used

* Supports both EQIU JOIN and non-EQIU JOIN
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;HASH JOIN&lt;/h4&gt;
&lt;pre&gt;&lt;code&gt;* Load the smaller of the two tables into hash memory and create a hash table using the join keys of both tables

* Scan both tables simultaneously

* The &amp;amp;quot;smaller data&amp;amp;quot; must come first in the leading table

* Can maximize utilization of system resources, but may consume excessive resources and raise concerns about system load

* Demonstrates fast processing speeds for large-scale data

* Available only with EQUAL JOIN

* Does not use indexes

* JOIN methods

  ```text
  먼저 선행 테이블을 결정, 선행 테이블에서 주어진 조건에 해당하는 레코드를 선택
  해당 행이 선택되면 JOIN Key를 기준으로 해시 함수를 사용
  해시 테이블을 메인 메모리에 생성, 후행 테이블에서 주어진 조건을 만족하는 행을 찾음
  후행 테이블의 JOIN Key를 사용해서 해시함수를 적용, 해당 버킷을 검색
  ```
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;PL/SQL&lt;/h2&gt;
&lt;p&gt;A language that extends SQL to enable various forms of procedural programming&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Structured in blocks, allowing for modularization by function&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Begins with a DECLARE statement, allowing variables and constants to be declared and used&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;DECLARE, BEGIN–END are mandatory; EXCEPTION is optional&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Uses various procedural language features such as DML, IF, and LOOP&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Built into Oracle and compatible with programs using the same language&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Improves application performance&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Allows the creation of Procedure, User-Defined Function, and Trigger objects.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Procedural code written within a procedure is processed by the PL/SQL engine, while standard SQL statements are processed by the SQL executor.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Distributed Database&lt;/h2&gt;
&lt;p&gt;A database system (DBMS) that controls physically separate databases over a network&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Improved performance: Distributed databases perform parallel processing, resulting in faster speeds&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Modular design allows for system updates without affecting other modules&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Capacity can be expanded by adding distributed databases&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Easy to protect critical data&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;High reliability&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Difficulties in management and control&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Difficulties in security management and integrity control&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Complex structure&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;메모

count(*): 전체 행의 수를 카운팅, null 포함
count({column_name}) null 을 제외한 행의 수를 카운팅
null: 모르는 값을 상징, 값의 부재를 말함
(null is null) = TRUE
null과의 모든 비교는 null 반환
0 혹은 &amp;#x27; &amp;#x27;과 동일한 값이 아님 

서브쿼리: SELECT문 내의 SELECT문이 반복 사용된 쿼리, 단일행 및 다중행으로 구분
- 정렬을 수행하는 ORDER BY를 사용할 수 없다.
- 여러 행을 반환하는 서브 쿼리는 다중 행 연산자를, 단일 행을 반환하는 서브쿼리는 단일 행 연산자를 사용
- 메인 쿼리에서 서브 쿼리의 컬럼을 자유롭게 사용할 수 없음
- EXIST는 True 혹은 False를 반환한다

스칼라 서브쿼리: 한 행과 한 컬럼만 반환하는 서브쿼리
인라인뷰: 서브쿼리가 FROM 절 내에 쓰여진 것

view 테이블
- 사용상의 편의를 위해 사용
- 수행속도의 향상을 위해 사용
- SQL의 성능을 향상시키기 위해 사용
- 임시적인 작업을 위해 사용
- 보안관리를 위해 사용

실행 순서
SELECT ALIAS =&amp;gt; FROM =&amp;gt; WHERE =&amp;gt; GROUP BY =&amp;gt; HAVING =&amp;gt; SELECT =&amp;gt; ORDER BY

조회 행수 제한
몇 번째 행을 조회하는지 부여하는 조건문
ROWNUM {row_number}: Oracle
TOP {row_number}: SQL Server
LIMIT {row_number}: MySQL

ROWID
해당 데이터가 어떤 데이터 파일 상에서 어느 블록에 저장되었는지 알려준다.
데이터베이스에 저장되어 있는 데이터를 구분할 수 있는 유일한 값이다.
ROWID의 번호는 데이터 블록에 데이터가 저장된 순서이다.
테이블에 데이터를 입력하면 자동으로 생성된다.
&lt;/code&gt;&lt;/pre&gt;
</content:encoded></item><item><title>[BOJ 17471, Python] Gerrymandering</title><link>https://www.traceoflight.dev/en/blog/boj17471/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/boj17471/</guid><description>Python Solution to BOJ Problem 17471, &amp;quot;Gerrymandering&amp;quot;</description><pubDate>Mon, 07 Nov 2022 11:14:53 GMT</pubDate><content:encoded>&lt;h3&gt;Problem Link&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/17471&quot;&gt;BOJ 17471&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Categories&lt;/h3&gt;
&lt;p&gt;Breadth-First Search (BFS), Brute Force Algorithm, Combinatorics, Depth-First Search (DFS), Graph Theory, Graph Traversal, Mathematics&lt;/p&gt;
&lt;h3&gt;Description&lt;/h3&gt;
&lt;p&gt;At first, I approached this problem as a Union-Find problem, trying to remove edges and experiment with different constraints, but it turned out to be a problem that required a straightforward solution.&lt;/p&gt;
&lt;p&gt;If we disregard the 0.5-second time limit, one might consider checking all combinations using depth-first search. However, since I was using Python, the short time limit led me to rule out a straightforward solution, which was a critical mistake.&lt;/p&gt;
&lt;p&gt;Considering that the number of districts is limited to a maximum of 10, this problem can easily be solved using brute force; in fact, focusing your efforts in the wrong direction could lead to failure.&lt;/p&gt;
&lt;p&gt;Therefore, the solution involves splitting each district into two parts to check if a valid electoral district is formed. If a valid district is formed, compare the population difference between the two districts; if the resulting value is smaller than the existing population difference, update it.&lt;/p&gt;
&lt;h3&gt;Solution Code&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;# 게리맨더링&lt;/span&gt;

&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; sys
&lt;span class=&quot;hljs-keyword&quot;&gt;from&lt;/span&gt; itertools &lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; combinations

&lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt; = sys.stdin.readline

&lt;span class=&quot;hljs-comment&quot;&gt;# 상한값 선언&lt;/span&gt;
INF = &lt;span class=&quot;hljs-number&quot;&gt;2000000000&lt;/span&gt;

&lt;span class=&quot;hljs-comment&quot;&gt;# 구역 갯수 입력&lt;/span&gt;
area_number = &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt;())

&lt;span class=&quot;hljs-comment&quot;&gt;# 구역별 인구 정보 입력&lt;/span&gt;
people_number = [&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;] + &lt;span class=&quot;hljs-built_in&quot;&gt;list&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;map&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;, &lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt;().split()))

&lt;span class=&quot;hljs-comment&quot;&gt;# 인접 구역 관계 그래프 입력&lt;/span&gt;
graph = [[] &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; _ &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(area_number + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;)]
&lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; area_idx &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, area_number + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;):
    near_area, *graph[area_idx] = &lt;span class=&quot;hljs-built_in&quot;&gt;map&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;, &lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt;().split())

&lt;span class=&quot;hljs-comment&quot;&gt;# 총 인구수 확인&lt;/span&gt;
max_people = &lt;span class=&quot;hljs-built_in&quot;&gt;sum&lt;/span&gt;(people_number)

&lt;span class=&quot;hljs-comment&quot;&gt;# 최소 차이값 변수 선언&lt;/span&gt;
min_difference = INF

&lt;span class=&quot;hljs-comment&quot;&gt;# 한 선거구의 포함될 모든 구역 수에 대해 체크 &lt;/span&gt;
&lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; areas &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, area_number // &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt; + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;):

    &lt;span class=&quot;hljs-comment&quot;&gt;# 모든 구역 중에서 한 선거구에 포함될 구역 확정&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; target_areas &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; combinations(&lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, area_number + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;), areas):

        &lt;span class=&quot;hljs-comment&quot;&gt;# 해당 선거구에 포함되는 구역 집합 선언 및 해당 선거구 인원수 변수 선언&lt;/span&gt;
        target_set = &lt;span class=&quot;hljs-built_in&quot;&gt;set&lt;/span&gt;(target_areas)
        sum_areas = &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;

        &lt;span class=&quot;hljs-comment&quot;&gt;# Depth First Search&lt;/span&gt;

        &lt;span class=&quot;hljs-comment&quot;&gt;# 집합에 포함된 한 구역에서 시작하는 깊이 탐색&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; first_area &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; target_set:

            &lt;span class=&quot;hljs-comment&quot;&gt;# 선거구 내 구역 수 체크 카운터 선언&lt;/span&gt;
            counter = &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;

            &lt;span class=&quot;hljs-comment&quot;&gt;# 방문 리스트 선언&lt;/span&gt;
            is_visited = [&lt;span class=&quot;hljs-literal&quot;&gt;False&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; _ &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(area_number + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;)]

            &lt;span class=&quot;hljs-comment&quot;&gt;# 깊이 탐색을 진행할 스택 선언 및 초기 조건 입력&lt;/span&gt;
            progress_stack = [first_area]
            sum_areas += people_number[first_area]
            is_visited[first_area] = &lt;span class=&quot;hljs-literal&quot;&gt;True&lt;/span&gt;

            &lt;span class=&quot;hljs-comment&quot;&gt;# 탐색 진행&lt;/span&gt;
            &lt;span class=&quot;hljs-keyword&quot;&gt;while&lt;/span&gt; progress_stack:

                &lt;span class=&quot;hljs-comment&quot;&gt;# 현재 구역 확인&lt;/span&gt;
                now_area = progress_stack.pop()

                &lt;span class=&quot;hljs-comment&quot;&gt;# 모든 인접 구역에 대해 확인&lt;/span&gt;
                &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; next_area &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; graph[now_area]:

                    &lt;span class=&quot;hljs-comment&quot;&gt;# 같은 선거구에 속해있고 방문하지 않았을 경우만 조사&lt;/span&gt;
                    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; next_area &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; target_set:
                        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;not&lt;/span&gt; is_visited[next_area]:

                            &lt;span class=&quot;hljs-comment&quot;&gt;# 방문 처리, 인구수 합산, 선거구 카운팅&lt;/span&gt;
                            is_visited[next_area] = &lt;span class=&quot;hljs-literal&quot;&gt;True&lt;/span&gt;
                            sum_areas += people_number[next_area]
                            counter += &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;

                            &lt;span class=&quot;hljs-comment&quot;&gt;# 다음 구역 스택에 추가&lt;/span&gt;
                            progress_stack.append(next_area)

            &lt;span class=&quot;hljs-comment&quot;&gt;# 1회의 조사로 선거구의 모든 정보를 획득하므로 반복하지 않음&lt;/span&gt;
            &lt;span class=&quot;hljs-keyword&quot;&gt;break&lt;/span&gt;

        &lt;span class=&quot;hljs-comment&quot;&gt;# 남은 구역들에 대해서 다른 하나의 선거구라 가정하고 깊이 탐색 진행&lt;/span&gt;

        other_set = &lt;span class=&quot;hljs-built_in&quot;&gt;set&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, area_number + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;)) - &lt;span class=&quot;hljs-built_in&quot;&gt;set&lt;/span&gt;(target_set)
        sum_other_areas = &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;

        &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; first_other_area &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; other_set:

            other_counter = &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;
            sum_other_areas += people_number[first_other_area]

            progress_stack = [first_other_area]
            is_visited[first_other_area] = &lt;span class=&quot;hljs-literal&quot;&gt;True&lt;/span&gt;

            &lt;span class=&quot;hljs-keyword&quot;&gt;while&lt;/span&gt; progress_stack:
                
                now_area = progress_stack.pop()

                &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; next_area &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; graph[now_area]:
                    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; next_area &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; other_set:
                        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;not&lt;/span&gt; is_visited[next_area]:
                            is_visited[next_area] = &lt;span class=&quot;hljs-literal&quot;&gt;True&lt;/span&gt;
                            sum_other_areas += people_number[next_area]
                            progress_stack.append(next_area)
                            other_counter += &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;

            &lt;span class=&quot;hljs-keyword&quot;&gt;break&lt;/span&gt;

        &lt;span class=&quot;hljs-comment&quot;&gt;# 양쪽 선거구를 조사했을 때 남는 구역이 없을 경우만 성립&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; counter + other_counter == area_number:

            &lt;span class=&quot;hljs-comment&quot;&gt;# 두 선거구의 인구 차이를 확인하여 기존값보다 작다면 갱신&lt;/span&gt;
            now_min = &lt;span class=&quot;hljs-built_in&quot;&gt;abs&lt;/span&gt;(sum_areas - sum_other_areas)
            &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; min_difference &amp;gt; now_min:
                min_difference = now_min

&lt;span class=&quot;hljs-comment&quot;&gt;# 한 번도 갱신하지 못했다면 선거구 분할 실패이므로 -1 출력&lt;/span&gt;
&lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; min_difference == INF:
    &lt;span class=&quot;hljs-built_in&quot;&gt;print&lt;/span&gt;(-&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;)

&lt;span class=&quot;hljs-comment&quot;&gt;# 갱신한 경우 결과를 출력&lt;/span&gt;
&lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;:
    &lt;span class=&quot;hljs-built_in&quot;&gt;print&lt;/span&gt;(min_difference)

&lt;/code&gt;&lt;/pre&gt;
</content:encoded></item><item><title>[BOJ 14438, Python] Sequences and Queries 17</title><link>https://www.traceoflight.dev/en/blog/boj14438/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/boj14438/</guid><description>Python Solution for Problem BOJ 14438, &amp;quot;Sequences and Queries 17&amp;quot;</description><pubDate>Tue, 01 Nov 2022 13:52:01 GMT</pubDate><content:encoded>&lt;h3&gt;Problem Link&lt;/h3&gt;
&lt;p&gt;[BOJ 14438](&lt;a href=&quot;https://www.acmicpc.net/problem/14438&quot;&gt;https://www.acmicpc.net/problem/14438&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;h3&gt;Categories&lt;/h3&gt;
&lt;p&gt;Segment Tree, Data Structures&lt;/p&gt;
&lt;h3&gt;Description&lt;/h3&gt;
&lt;p&gt;I believe this is the most common type of segment tree problem encountered by beginners.&lt;/p&gt;
&lt;p&gt;Compared to a linear list, a segment tree offers the advantage of being constructed in O(NlogN) time for various operations such as range sum, range product, and maximum value within a range, while allowing access to information for each range in O(logN) time.&lt;/p&gt;
&lt;p&gt;This problem can be broadly divided into three functions: the function to construct the segment tree, the function to retrieve range information, and the function to update the values.&lt;/p&gt;
&lt;h4&gt;Construction Function&lt;/h4&gt;
&lt;p&gt;Looking first at the function that constructs the segment tree (&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;make_segtree&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;target_list: &lt;span class=&quot;hljs-built_in&quot;&gt;list&lt;/span&gt;, result_list: &lt;span class=&quot;hljs-built_in&quot;&gt;list&lt;/span&gt;, start: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;, end:&lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;, now_node: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;&lt;/span&gt;) -&amp;gt; &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;:
    &lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;&amp;#x27;&amp;#x27;
    최소 숫자 정보를 담는 세그먼트 트리를 생성하는 함수
    &amp;#x27;&amp;#x27;&amp;#x27;&lt;/span&gt;

    &lt;span class=&quot;hljs-comment&quot;&gt;# 포인터가 한 곳으로 모인 경우&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; start == end:

        &lt;span class=&quot;hljs-comment&quot;&gt;# 해당 노드는 포인터가 가리키는 인덱스의 값과 동일&lt;/span&gt;
        result_list[now_node] = target_list[start]

    &lt;span class=&quot;hljs-comment&quot;&gt;# 포인터가 범위를 나타내는 경우&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;:

        &lt;span class=&quot;hljs-comment&quot;&gt;# Devide and Conquer Algorithm&lt;/span&gt;

        &lt;span class=&quot;hljs-comment&quot;&gt;# 중간 지점 선언&lt;/span&gt;
        mid = (start + end) // &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;

        &lt;span class=&quot;hljs-comment&quot;&gt;# 중간 지점을 기준으로 구간을 분할하여 최소값으로 갱신&lt;/span&gt;
        val_1 = make_segtree(target_list, result_list, start, mid, &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt; * now_node)
        val_2 = make_segtree(target_list, result_list, mid + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, end, &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt; * now_node + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;)

        &lt;span class=&quot;hljs-comment&quot;&gt;# 두 구간의 최소값을 비교하여 둘 중 최소값을 현재 노드에 기록&lt;/span&gt;
        result_list[now_node] = &lt;span class=&quot;hljs-built_in&quot;&gt;min&lt;/span&gt;(val_1, val_2)

    &lt;span class=&quot;hljs-comment&quot;&gt;# 현재 노드의 값을 반환&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; result_list[now_node]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;), it essentially demonstrates the process of splitting the entire list into intervals and storing information about each interval in the corresponding nodes of the segment tree.&lt;/p&gt;
&lt;p&gt;Since a recursive approach is used, the recursion continues until the interval length reaches 1, building up the recursion stack along the way. When this condition is met, the information for a single list value is stored at that address.&lt;/p&gt;
&lt;p&gt;Subsequently, using the returned values, nodes that are not leaf nodes filter out values that meet the conditions, eventually reaching the root.&lt;/p&gt;
&lt;p&gt;Therefore, the value stored in the root node is the value that best matches the conditions specified in the problem across the entire range.&lt;/p&gt;
&lt;h4&gt;Search Function&lt;/h4&gt;
&lt;p&gt;Next, let’s examine the function that finds the minimum value within a range:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;find_min_number&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;target_tree: &lt;span class=&quot;hljs-built_in&quot;&gt;list&lt;/span&gt;, start: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;, end: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;, left: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;, right: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;, now_node: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;&lt;/span&gt;) -&amp;gt; &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;:
    &lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;&amp;#x27;&amp;#x27;
    해당 구간의 최소값을 찾는 함수
    &amp;#x27;&amp;#x27;&amp;#x27;&lt;/span&gt;

    &lt;span class=&quot;hljs-comment&quot;&gt;# 범위 내로 포인터가 좁혀진 경우&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; left &amp;lt;= start &lt;span class=&quot;hljs-keyword&quot;&gt;and&lt;/span&gt; right &amp;gt;= end:

        &lt;span class=&quot;hljs-comment&quot;&gt;# 현재 노드값을 반환&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; target_tree[now_node]

    &lt;span class=&quot;hljs-comment&quot;&gt;# 범위를 아예 벗어난 경우&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;elif&lt;/span&gt; left &amp;gt; end &lt;span class=&quot;hljs-keyword&quot;&gt;or&lt;/span&gt; right &amp;lt; start:

        &lt;span class=&quot;hljs-comment&quot;&gt;# None 값을 반환&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hljs-literal&quot;&gt;None&lt;/span&gt;

    &lt;span class=&quot;hljs-comment&quot;&gt;# 범위가 걸친 경우&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;:

        &lt;span class=&quot;hljs-comment&quot;&gt;# Devide and Conquer Algorithm&lt;/span&gt;

        &lt;span class=&quot;hljs-comment&quot;&gt;# 중간 지점 선언&lt;/span&gt;
        mid = (start + end) // &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;

        &lt;span class=&quot;hljs-comment&quot;&gt;# 중간 지점을 기준으로 구간을 분할하여 값을 확인&lt;/span&gt;
        val_1 = find_min_number(target_tree, start, mid, left, right, &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt; * now_node)
        val_2 = find_min_number(target_tree, mid + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, end, left, right, &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt; * now_node + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;)

        &lt;span class=&quot;hljs-comment&quot;&gt;# 반환된 값들 중 None이 존재하는 경우&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; val_1 &lt;span class=&quot;hljs-keyword&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;hljs-literal&quot;&gt;None&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;and&lt;/span&gt; val_2 &lt;span class=&quot;hljs-keyword&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;hljs-literal&quot;&gt;None&lt;/span&gt;:
            &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hljs-literal&quot;&gt;None&lt;/span&gt;

        &lt;span class=&quot;hljs-keyword&quot;&gt;elif&lt;/span&gt; val_1 &lt;span class=&quot;hljs-keyword&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;hljs-literal&quot;&gt;None&lt;/span&gt;:
            &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; val_2

        &lt;span class=&quot;hljs-keyword&quot;&gt;elif&lt;/span&gt; val_2 &lt;span class=&quot;hljs-keyword&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;hljs-literal&quot;&gt;None&lt;/span&gt;:
            &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; val_1

        &lt;span class=&quot;hljs-comment&quot;&gt;# None이 없다면&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;:

            &lt;span class=&quot;hljs-comment&quot;&gt;# 두 구간의 최소값 중에서 더 작은 값을 반환&lt;/span&gt;
            &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;min&lt;/span&gt;(val_1, val_2)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;. Essentially, if the range I’m searching for is included, the function proceeds to narrow it down until it contains only the exact range I’m looking for, then returns that value so the parent function can verify it.&lt;/p&gt;
&lt;p&gt;If the range is exceeded, it returns &lt;code&gt;None&lt;/code&gt;. By applying pruning based on these conditions, we can ensure that only ranges within the specified limits are selected and compared.&lt;/p&gt;
&lt;h4&gt;Modification Function&lt;/h4&gt;
&lt;p&gt;Finally, let’s look at the function that applies changes when a value is modified:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;
&lt;span class=&quot;hljs-keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;change_segtree&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;target_tree: &lt;span class=&quot;hljs-built_in&quot;&gt;list&lt;/span&gt;, start: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;, end: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;, target_idx: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;, target_val: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;, now_node: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;&lt;/span&gt;) -&amp;gt; &lt;span class=&quot;hljs-literal&quot;&gt;None&lt;/span&gt;:
    &lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;&amp;#x27;&amp;#x27;
    리스트에 생긴 변경점을 트리에 반영하는 함수
    &amp;#x27;&amp;#x27;&amp;#x27;&lt;/span&gt;
    
    &lt;span class=&quot;hljs-comment&quot;&gt;# 포인터가 한 곳으로 모인 경우&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; start == end:

        &lt;span class=&quot;hljs-comment&quot;&gt;# 목표로 하는 인덱스랑 동일하다면 변경값을 반영&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; start == target_idx:
            target_tree[now_node] = target_val

    &lt;span class=&quot;hljs-comment&quot;&gt;# 포인터가 범위로 주어진 경우&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;:

        &lt;span class=&quot;hljs-comment&quot;&gt;# 목표 인덱스가 범위 내에 존재할 경우에만 갱신 가능성 존재&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; start &amp;lt;= target_idx &amp;lt;= end:

            &lt;span class=&quot;hljs-comment&quot;&gt;# Devide and Conquer Algorithm&lt;/span&gt;

            &lt;span class=&quot;hljs-comment&quot;&gt;# 중간 지점 선언&lt;/span&gt;
            mid = (start + end) // &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;

            &lt;span class=&quot;hljs-comment&quot;&gt;# 중간 지점을 기준으로 변경될 수 있는 인덱스를 재조사&lt;/span&gt;
            change_segtree(target_tree, start, mid, target_idx, target_val, &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt; * now_node)
            change_segtree(target_tree, mid + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, end, target_idx, target_val, &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt; * now_node + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;)

        &lt;span class=&quot;hljs-comment&quot;&gt;# 하위 노드들의 갱신이 진행된 이후 현재 노드의 갱신 진행&lt;/span&gt;
        target_tree[now_node] = &lt;span class=&quot;hljs-built_in&quot;&gt;min&lt;/span&gt;(target_tree[&lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt; * now_node], target_tree[&lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt; * now_node + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;])

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;. Since all values within the interval containing the index of the modified value must be updated, the function determines whether the interval includes that index or not.&lt;/p&gt;
&lt;p&gt;Just like the creation function, a recursive stack is built until it narrows down to a single index. Starting with the modification of the node containing only that single index, the function returns while reflecting the updated values, and finally checks all the way down to the root node to complete the process.&lt;/p&gt;
&lt;h3&gt;Solution Code&lt;/h3&gt;
&lt;p&gt;Through the above process, all the operations required by the problem can be modularized. You can view the full code below.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;# 수열과 쿼리 17&lt;/span&gt;

&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; sys
&lt;span class=&quot;hljs-keyword&quot;&gt;from&lt;/span&gt; math &lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; ceil, log2

&lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt; = sys.stdin.readline

&lt;span class=&quot;hljs-keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;make_segtree&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;target_list: &lt;span class=&quot;hljs-built_in&quot;&gt;list&lt;/span&gt;, result_list: &lt;span class=&quot;hljs-built_in&quot;&gt;list&lt;/span&gt;, start: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;, end:&lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;, now_node: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;&lt;/span&gt;) -&amp;gt; &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;:
    &lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;&amp;#x27;&amp;#x27;
    최소 숫자 정보를 담는 세그먼트 트리를 생성하는 함수
    &amp;#x27;&amp;#x27;&amp;#x27;&lt;/span&gt;

    &lt;span class=&quot;hljs-comment&quot;&gt;# 포인터가 한 곳으로 모인 경우&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; start == end:

        &lt;span class=&quot;hljs-comment&quot;&gt;# 해당 노드는 포인터가 가리키는 인덱스의 값과 동일&lt;/span&gt;
        result_list[now_node] = target_list[start]

    &lt;span class=&quot;hljs-comment&quot;&gt;# 포인터가 범위를 나타내는 경우&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;:

        &lt;span class=&quot;hljs-comment&quot;&gt;# Devide and Conquer Algorithm&lt;/span&gt;

        &lt;span class=&quot;hljs-comment&quot;&gt;# 중간 지점 선언&lt;/span&gt;
        mid = (start + end) // &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;

        &lt;span class=&quot;hljs-comment&quot;&gt;# 중간 지점을 기준으로 구간을 분할하여 최소값으로 갱신&lt;/span&gt;
        val_1 = make_segtree(target_list, result_list, start, mid, &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt; * now_node)
        val_2 = make_segtree(target_list, result_list, mid + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, end, &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt; * now_node + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;)

        &lt;span class=&quot;hljs-comment&quot;&gt;# 두 구간의 최소값을 비교하여 둘 중 최소값을 현재 노드에 기록&lt;/span&gt;
        result_list[now_node] = &lt;span class=&quot;hljs-built_in&quot;&gt;min&lt;/span&gt;(val_1, val_2)

    &lt;span class=&quot;hljs-comment&quot;&gt;# 현재 노드의 값을 반환&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; result_list[now_node]

&lt;span class=&quot;hljs-keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;find_min_number&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;target_tree: &lt;span class=&quot;hljs-built_in&quot;&gt;list&lt;/span&gt;, start: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;, end: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;, left: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;, right: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;, now_node: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;&lt;/span&gt;) -&amp;gt; &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;:
    &lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;&amp;#x27;&amp;#x27;
    해당 구간의 최소값을 찾는 함수
    &amp;#x27;&amp;#x27;&amp;#x27;&lt;/span&gt;

    &lt;span class=&quot;hljs-comment&quot;&gt;# 범위 내로 포인터가 좁혀진 경우&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; left &amp;lt;= start &lt;span class=&quot;hljs-keyword&quot;&gt;and&lt;/span&gt; right &amp;gt;= end:

        &lt;span class=&quot;hljs-comment&quot;&gt;# 현재 노드값을 반환&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; target_tree[now_node]

    &lt;span class=&quot;hljs-comment&quot;&gt;# 범위를 아예 벗어난 경우&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;elif&lt;/span&gt; left &amp;gt; end &lt;span class=&quot;hljs-keyword&quot;&gt;or&lt;/span&gt; right &amp;lt; start:

        &lt;span class=&quot;hljs-comment&quot;&gt;# None 값을 반환&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hljs-literal&quot;&gt;None&lt;/span&gt;

    &lt;span class=&quot;hljs-comment&quot;&gt;# 범위가 걸친 경우&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;:

        &lt;span class=&quot;hljs-comment&quot;&gt;# Devide and Conquer Algorithm&lt;/span&gt;

        &lt;span class=&quot;hljs-comment&quot;&gt;# 중간 지점 선언&lt;/span&gt;
        mid = (start + end) // &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;

        &lt;span class=&quot;hljs-comment&quot;&gt;# 중간 지점을 기준으로 구간을 분할하여 값을 확인&lt;/span&gt;
        val_1 = find_min_number(target_tree, start, mid, left, right, &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt; * now_node)
        val_2 = find_min_number(target_tree, mid + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, end, left, right, &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt; * now_node + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;)

        &lt;span class=&quot;hljs-comment&quot;&gt;# 반환된 값들 중 None이 존재하는 경우&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; val_1 &lt;span class=&quot;hljs-keyword&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;hljs-literal&quot;&gt;None&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;and&lt;/span&gt; val_2 &lt;span class=&quot;hljs-keyword&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;hljs-literal&quot;&gt;None&lt;/span&gt;:
            &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hljs-literal&quot;&gt;None&lt;/span&gt;

        &lt;span class=&quot;hljs-keyword&quot;&gt;elif&lt;/span&gt; val_1 &lt;span class=&quot;hljs-keyword&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;hljs-literal&quot;&gt;None&lt;/span&gt;:
            &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; val_2

        &lt;span class=&quot;hljs-keyword&quot;&gt;elif&lt;/span&gt; val_2 &lt;span class=&quot;hljs-keyword&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;hljs-literal&quot;&gt;None&lt;/span&gt;:
            &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; val_1

        &lt;span class=&quot;hljs-comment&quot;&gt;# None이 없다면&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;:

            &lt;span class=&quot;hljs-comment&quot;&gt;# 두 구간의 최소값 중에서 더 작은 값을 반환&lt;/span&gt;
            &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;min&lt;/span&gt;(val_1, val_2)

&lt;span class=&quot;hljs-keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;change_segtree&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;target_tree: &lt;span class=&quot;hljs-built_in&quot;&gt;list&lt;/span&gt;, start: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;, end: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;, target_idx: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;, target_val: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;, now_node: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;&lt;/span&gt;) -&amp;gt; &lt;span class=&quot;hljs-literal&quot;&gt;None&lt;/span&gt;:
    &lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;&amp;#x27;&amp;#x27;
    리스트에 생긴 변경점을 트리에 반영하는 함수
    &amp;#x27;&amp;#x27;&amp;#x27;&lt;/span&gt;
    
    &lt;span class=&quot;hljs-comment&quot;&gt;# 포인터가 한 곳으로 모인 경우&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; start == end:

        &lt;span class=&quot;hljs-comment&quot;&gt;# 목표로 하는 인덱스랑 동일하다면 변경값을 반영&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; start == target_idx:
            target_tree[now_node] = target_val

    &lt;span class=&quot;hljs-comment&quot;&gt;# 포인터가 범위로 주어진 경우&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;:

        &lt;span class=&quot;hljs-comment&quot;&gt;# 목표 인덱스가 범위 내에 존재할 경우에만 갱신 가능성 존재&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; start &amp;lt;= target_idx &amp;lt;= end:

            &lt;span class=&quot;hljs-comment&quot;&gt;# Devide and Conquer Algorithm&lt;/span&gt;

            &lt;span class=&quot;hljs-comment&quot;&gt;# 중간 지점 선언&lt;/span&gt;
            mid = (start + end) // &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;

            &lt;span class=&quot;hljs-comment&quot;&gt;# 중간 지점을 기준으로 변경될 수 있는 인덱스를 재조사&lt;/span&gt;
            change_segtree(target_tree, start, mid, target_idx, target_val, &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt; * now_node)
            change_segtree(target_tree, mid + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, end, target_idx, target_val, &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt; * now_node + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;)

        &lt;span class=&quot;hljs-comment&quot;&gt;# 하위 노드들의 갱신이 진행된 이후 현재 노드의 갱신 진행&lt;/span&gt;
        target_tree[now_node] = &lt;span class=&quot;hljs-built_in&quot;&gt;min&lt;/span&gt;(target_tree[&lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt; * now_node], target_tree[&lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt; * now_node + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;])

&lt;span class=&quot;hljs-comment&quot;&gt;# 수열의 크기 및 수열 정보 입력&lt;/span&gt;
target_length = &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt;())
target_arr = [&lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;*&amp;#x27;&lt;/span&gt;] + &lt;span class=&quot;hljs-built_in&quot;&gt;list&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;map&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;, &lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt;().split()))

&lt;span class=&quot;hljs-comment&quot;&gt;# 수열의 구간 최소 숫자를 담을 세그먼트 트리 리스트 선언&lt;/span&gt;
segtree_arr = [&lt;span class=&quot;hljs-literal&quot;&gt;None&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; _ &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;pow&lt;/span&gt;(&lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;, ceil(log2(target_length) + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;)))]

&lt;span class=&quot;hljs-comment&quot;&gt;# 함수를 호출하여 트리 생성&lt;/span&gt;
make_segtree(target_arr, segtree_arr, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, target_length, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;)

&lt;span class=&quot;hljs-comment&quot;&gt;# 퀴리 갯수 입력 및 출력 리스트 선언&lt;/span&gt;
query_number = &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt;())
output = []

&lt;span class=&quot;hljs-comment&quot;&gt;# 쿼리 실행&lt;/span&gt;
&lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; _ &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(query_number):

    &lt;span class=&quot;hljs-comment&quot;&gt;# 각 쿼리의 정보&lt;/span&gt;
    order_type, num_1, num_2 = &lt;span class=&quot;hljs-built_in&quot;&gt;map&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;, &lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt;().split())

    &lt;span class=&quot;hljs-comment&quot;&gt;# 타입 1의 경우&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; order_type == &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;:

        &lt;span class=&quot;hljs-comment&quot;&gt;# 리스트 값을 변경 및 함수를 호출하여 트리에 반영&lt;/span&gt;
        target_arr[num_1] = num_2
        change_segtree(segtree_arr, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, target_length, num_1, num_2, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;)

    &lt;span class=&quot;hljs-comment&quot;&gt;# 타입 2의 경우&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;elif&lt;/span&gt; order_type == &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;:

        &lt;span class=&quot;hljs-comment&quot;&gt;# 함수를 호출하여 해당 구간의 최소 숫자를 출력 리스트에 추가&lt;/span&gt;
        output.append(find_min_number(segtree_arr, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, target_length, num_1, num_2, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;))

&lt;span class=&quot;hljs-comment&quot;&gt;# 결과 출력&lt;/span&gt;
&lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; result &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; output:
    &lt;span class=&quot;hljs-built_in&quot;&gt;print&lt;/span&gt;(result)
&lt;/code&gt;&lt;/pre&gt;
</content:encoded></item><item><title>Git Intro</title><link>https://www.traceoflight.dev/en/blog/git-intro/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/git-intro/</guid><description>A summary of storage systems prior to Git, as well as Git&apos;s operation and commands.</description><pubDate>Fri, 28 Oct 2022 13:19:01 GMT</pubDate><content:encoded>&lt;h1&gt;Intro&lt;/h1&gt;
&lt;p&gt;This post summarizes the essential information I gathered while studying Git. Unless there are significant changes or further study is required, I believe this will serve as both an introduction and the final post.&lt;/p&gt;
&lt;h2&gt;What is Git?&lt;/h2&gt;
&lt;p&gt;It is a type of version control tool that records changes to files and allows the records from a specific point in time to be reused.&lt;/p&gt;
&lt;h3&gt;Local Version Control&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Copying Directories&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The most naive method&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You might accidentally modify files incorrectly or copy them incorrectly.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;ol start=&quot;2&quot;&gt;
&lt;li&gt;VCS (Version Control System)&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Manages file change information using a database.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Revision Control Systems are a representative example.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Manages Patch Sets (parts of a file that are changed).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;By utilizing a series of Patch Sets, all files can be reverted to a specific point in time.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Centralized Version Control&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Collaboration with other developers is frequent when working on a project.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In such cases, it is advantageous to have a separate server managing files, where clients receive and use files from the central server.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If a problem occurs with the central server and there is no system backup, the entire history can be lost; this is a problem that also existed locally.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Distributed Version Control System&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;It replicates the repository and history simultaneously, rather than simply storing snapshots.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If a problem occurs on the server, work can be resumed using the clone.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;It is also possible to restore the server by selecting any client.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The existence of remote repositories enables various forms of collaboration.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;GitHub is also a type of remote repository.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;General Usage&lt;/h2&gt;
&lt;h3&gt;Configuration and File Access Commands&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;# 전역 사용자 설정&lt;/span&gt;
git config --global user.name {name} &lt;span class=&quot;hljs-comment&quot;&gt;# 이름&lt;/span&gt;
git config --global user.email {email_address} &lt;span class=&quot;hljs-comment&quot;&gt;# 이메일&lt;/span&gt;

&lt;span class=&quot;hljs-comment&quot;&gt;# 로컬 사용자 설정 (해당 디렉토리에서 실행)&lt;/span&gt;
git config user.name {name} &lt;span class=&quot;hljs-comment&quot;&gt;# 이름&lt;/span&gt;
git config user.email {email_address} &lt;span class=&quot;hljs-comment&quot;&gt;# 이메일&lt;/span&gt;

&lt;span class=&quot;hljs-comment&quot;&gt;# 설정 조회&lt;/span&gt;
git config --list

&lt;span class=&quot;hljs-comment&quot;&gt;# 생성&lt;/span&gt;
git &lt;span class=&quot;hljs-built_in&quot;&gt;mkdir&lt;/span&gt; {path}/{folder_name} &lt;span class=&quot;hljs-comment&quot;&gt;# 폴더&lt;/span&gt;
git &lt;span class=&quot;hljs-built_in&quot;&gt;touch&lt;/span&gt; {file_name} &lt;span class=&quot;hljs-comment&quot;&gt;# 파일&lt;/span&gt;
git init &lt;span class=&quot;hljs-comment&quot;&gt;# 파일 관리 시스템&lt;/span&gt;

&lt;span class=&quot;hljs-comment&quot;&gt;# 저장소 및 히스토리 복제&lt;/span&gt;
git &lt;span class=&quot;hljs-built_in&quot;&gt;clone&lt;/span&gt; {repository_url}

&lt;span class=&quot;hljs-comment&quot;&gt;# 원격 저장소&lt;/span&gt;
git remote add {remote_repo_name} {remote_repo_url} &lt;span class=&quot;hljs-comment&quot;&gt;# 추가&lt;/span&gt;
git remote -v &lt;span class=&quot;hljs-comment&quot;&gt;# 정보 확인&lt;/span&gt;

&lt;span class=&quot;hljs-comment&quot;&gt;# commit history&lt;/span&gt;
git &lt;span class=&quot;hljs-built_in&quot;&gt;log&lt;/span&gt;
git &lt;span class=&quot;hljs-built_in&quot;&gt;log&lt;/span&gt; --oneline &lt;span class=&quot;hljs-comment&quot;&gt;# 정보 표시 간략화&lt;/span&gt;
git &lt;span class=&quot;hljs-built_in&quot;&gt;log&lt;/span&gt; --all &lt;span class=&quot;hljs-comment&quot;&gt;# 현재 head 이후의 최신 기록들을 포함한 전체 정보를 표시&lt;/span&gt;
git &lt;span class=&quot;hljs-built_in&quot;&gt;log&lt;/span&gt; --graph &lt;span class=&quot;hljs-comment&quot;&gt;# 브랜치를 시각화하여 분기를 표현한 그래프 형태로 정보를 표시&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Commands Used for Repository Management&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;git status &lt;span class=&quot;hljs-comment&quot;&gt;# 변경사항을 확인하는 명령어&lt;/span&gt;
git commit -m {message} &lt;span class=&quot;hljs-comment&quot;&gt;# 현재 스테이지에 존재하는 변경 사항을 커밋&lt;/span&gt;

git add {file_name} &lt;span class=&quot;hljs-comment&quot;&gt;# 특정한 파일을 스테이지에 추가하는 경우&lt;/span&gt;
git add . &lt;span class=&quot;hljs-comment&quot;&gt;# 해당 레포지토리의 변경사항을 전부 스테이지에 추가하는 경우&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Git Undoing&lt;/h2&gt;
&lt;h3&gt;Clearing the Stage&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;git &lt;span class=&quot;hljs-built_in&quot;&gt;rm&lt;/span&gt; --cached &lt;span class=&quot;hljs-comment&quot;&gt;# root commit이 존재하지 않을 때&lt;/span&gt;
git restore --staged &lt;span class=&quot;hljs-comment&quot;&gt;# root commit이 존재할 때&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Modifying a Commit&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;git commit --amend 
&lt;span class=&quot;hljs-comment&quot;&gt;# 스테이지에 파일이 없는 경우: 직전 커밋의 메시지를 수정&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt;# 스테이지에 파일이 있는 경우: 기존 커밋에 현재 스테이지를 더하여 덮어쓰기 진행&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Reverting All Commits Up to a Specific Point&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;git reset --soft {commit_id} &lt;span class=&quot;hljs-comment&quot;&gt;# 미래 파일들 전부 stage에 돌려놓음&lt;/span&gt;
git reset --mixed {commit_id} &lt;span class=&quot;hljs-comment&quot;&gt;# default, 미래 파일들을 전부 working directory에 유지 (add 필요)&lt;/span&gt;
git reset --hard {commit_id} &lt;span class=&quot;hljs-comment&quot;&gt;# 미래 파일 전부 제거&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Removing Past Commits&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;git revert {commit_id} &lt;span class=&quot;hljs-comment&quot;&gt;# 과거 commit을 제거 후, 제거했음을 commit으로 추가&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Reset is unsuitable for collaboration because it reduces the number of commits; therefore, using revert instead of reset is recommended for collaboration.&lt;/p&gt;
&lt;h2&gt;Git Branch&lt;/h2&gt;
&lt;p&gt;Branch: A mechanism that helps divide the workspace and allow for independent work.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Allows you to maintain the original state. Safety&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Increased collaboration efficiency by performing a single task on a single branch&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In the case of Git, branch creation is fast and file sizes are small&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Related Commands&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;# 조회&lt;/span&gt;
git branch &lt;span class=&quot;hljs-comment&quot;&gt;# 로컬 저장소의 브랜치 대상&lt;/span&gt;
git branch -r &lt;span class=&quot;hljs-comment&quot;&gt;# 원격 저장소의 브랜치 대상&lt;/span&gt;

&lt;span class=&quot;hljs-comment&quot;&gt;# 생성&lt;/span&gt;
git branch {branch_name}
git branch {branch_name} {commit_id} &lt;span class=&quot;hljs-comment&quot;&gt;# 특정 커밋 지점을 기준점으로 생성&lt;/span&gt;

&lt;span class=&quot;hljs-comment&quot;&gt;# 제거&lt;/span&gt;
git branch -d {branch_name} &lt;span class=&quot;hljs-comment&quot;&gt;# 병합 완료된 경우&lt;/span&gt;
git branch -D {branch_name} &lt;span class=&quot;hljs-comment&quot;&gt;# 병합하지 못한 브랜치 강제 삭제&lt;/span&gt;

&lt;span class=&quot;hljs-comment&quot;&gt;# 브랜치 이동&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt;# 이동 전 반드시 현재 브랜치의 변경사항을 기록할 것&lt;/span&gt;
git switch {branch_name} &lt;span class=&quot;hljs-comment&quot;&gt;# 이미 있는 브랜치로 이동&lt;/span&gt;
git switch -c {branch_name} &lt;span class=&quot;hljs-comment&quot;&gt;# 해당 이름의 브랜치를 생성 후 이동&lt;/span&gt;
git switch -c {branch_name} {commit_id} &lt;span class=&quot;hljs-comment&quot;&gt;# 특정 커밋 지점을 기준점으로 하는 해당 이름의 브랜치를 생성 후 이동&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Git Merge&lt;/h2&gt;
&lt;p&gt;The process of merging branched branches&lt;/p&gt;
&lt;h3&gt;Types of Merging&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Fast-Forward: Moves the commit pointed to by the branch to the very beginning&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;3-Way Merge: A merge using the 2 most recent commits from each branch + the common ancestor of the two branches&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Merge Conflict: Conflicts occur when the same file is modified =&amp;gt; Resolve the conflict and then proceed with a 3-Way Merge&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;# 해당 브랜치를 현재 위치한 브랜치에 병합&lt;/span&gt;
git merge {merged_branch}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Git Fork&lt;/h2&gt;
&lt;p&gt;Clone a remote repository without ownership; mainly used when there are multiple collaborators, such as with open source projects&lt;/p&gt;
&lt;h3&gt;The process of my commits being reflected in the forked source&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;#&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt;#    원본 원격 저장소 (upstream) &amp;lt;----------- 복제본 원격 저장소 (origin)&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt;#                \           merge request      /|&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt;#                 \                              |&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt;#                  \                 push branch | pull master&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt;#                   \                            |&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt;#                    \     ( pull upstream )     |/&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt;#                     ------------------&amp;gt; 로컬 저장소 (user)&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt;#&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Clone the original repository to my remote repository&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;From that remote repository to the local Save&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Create a branch locally, work on it, and commit the changes.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Push a merge request for the changes to the original remote repository.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Merge the changes in the original remote repository.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Pull the changes from the original repository.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;pull upstream&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;sync origin &amp;amp; pull origin&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;ol start=&quot;7&quot;&gt;
&lt;li&gt;Remove my merged branch locally.&lt;/li&gt;
&lt;/ol&gt;
</content:encoded></item><item><title>[BOJ 7579, Python] Apps</title><link>https://www.traceoflight.dev/en/blog/boj7579/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/boj7579/</guid><description>BOJ 7579, Python Solution to the &quot;App&quot; Problem</description><pubDate>Fri, 28 Oct 2022 10:13:23 GMT</pubDate><content:encoded>&lt;h3&gt;Problem link&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;@@tlp1@@&quot;&gt;boj 7579&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Classification&lt;/h3&gt;
&lt;p&gt;Dynamic Programming (DP), Knapsack problems&lt;/p&gt;
&lt;h3&gt;Description&lt;/h3&gt;
&lt;p&gt;Personally, I think the most important thing to look at when solving this problem was the problem conditions.&lt;/p&gt;
&lt;p&gt;The memory bytes in use condition was 10^7, the number of active apps had to be at most 100, and the cost had to be less than or equal to 100.&lt;/p&gt;
&lt;p&gt;This was a very large range to use a memory byte condition to check for false positives, so I decided to set the cost to the appropriate variable and assign an address to every cost to record how much memory I could save.&lt;/p&gt;
&lt;p&gt;I guessed that DP should be used here and further designed a solution using the knapsack algorithm, which used to update the existing value based on the value when cost and value existed.&lt;/p&gt;
&lt;h3&gt;Solving code&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;# 앱&lt;/span&gt;

&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; sys

&lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt; = sys.stdin.readline

&lt;span class=&quot;hljs-comment&quot;&gt;# 앱 갯수, 필요 메모리 입력&lt;/span&gt;
app_number, need_memory = &lt;span class=&quot;hljs-built_in&quot;&gt;map&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;, &lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt;().split())

&lt;span class=&quot;hljs-comment&quot;&gt;# 각 앱의 메모리와 비활성화 시의 비용 입력&lt;/span&gt;
app_memories = &lt;span class=&quot;hljs-built_in&quot;&gt;list&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;map&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;, &lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt;().split()))
disable_costs = &lt;span class=&quot;hljs-built_in&quot;&gt;list&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;map&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;, &lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt;().split()))

&lt;span class=&quot;hljs-comment&quot;&gt;# 앱의 메모리와 비용 합쳐서 짝을 지어줌&lt;/span&gt;
memories_and_costs = &lt;span class=&quot;hljs-built_in&quot;&gt;list&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;zip&lt;/span&gt;(app_memories, disable_costs))

&lt;span class=&quot;hljs-comment&quot;&gt;# 최대 필요 비용 연산&lt;/span&gt;
sum_cost = &lt;span class=&quot;hljs-built_in&quot;&gt;sum&lt;/span&gt;(disable_costs)

&lt;span class=&quot;hljs-comment&quot;&gt;# 각 비용별 최대 절약 가능한 메모리 리스트 선언&lt;/span&gt;
cost_list = [&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; _ &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(sum_cost + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;)]

&lt;span class=&quot;hljs-comment&quot;&gt;# Knapsack Algorithm&lt;/span&gt;

&lt;span class=&quot;hljs-comment&quot;&gt;# 모든 앱에 대해 확인&lt;/span&gt;
&lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; now_memory, now_cost &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; memories_and_costs:

    &lt;span class=&quot;hljs-comment&quot;&gt;# 최대 필요 비용까지 조사&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; last_cost &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(sum_cost, -&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, -&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;):

        &lt;span class=&quot;hljs-comment&quot;&gt;# 최대 비용을 넘지 않는 선에서 확인&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; last_cost + now_cost &amp;lt;= sum_cost:

            &lt;span class=&quot;hljs-comment&quot;&gt;# 기존 최대값보다 컸다면 갱신&lt;/span&gt;
            cost_list[last_cost + now_cost] = &lt;span class=&quot;hljs-built_in&quot;&gt;max&lt;/span&gt;(
                cost_list[last_cost + now_cost], cost_list[last_cost] + now_memory
            )

&lt;span class=&quot;hljs-comment&quot;&gt;# 비용을 0에서부터 조사해서 기준 메모리 이상을 절약한 경우의 비용을 출력&lt;/span&gt;
&lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; idx &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(sum_cost + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;):
    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; cost_list[idx] &amp;gt;= need_memory:
        &lt;span class=&quot;hljs-built_in&quot;&gt;print&lt;/span&gt;(idx)
        &lt;span class=&quot;hljs-keyword&quot;&gt;break&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;
</content:encoded></item><item><title>[BOJ 15683, Python] Surveillance</title><link>https://www.traceoflight.dev/en/blog/boj15683/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/boj15683/</guid><description>Python Solution for BOJ Problem 15683, &amp;quot;Surveillance&amp;quot;</description><pubDate>Sun, 23 Oct 2022 10:46:34 GMT</pubDate><content:encoded>&lt;h3&gt;Problem Link&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/15683&quot;&gt;BOJ 15683&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Categories&lt;/h3&gt;
&lt;p&gt;Brute-force algorithm, Implementation, Simulation&lt;/p&gt;
&lt;h3&gt;Description&lt;/h3&gt;
&lt;p&gt;Although this problem is categorized as a brute-force algorithm, I used a backtracking algorithm to implement it.&lt;/p&gt;
&lt;p&gt;Basically, I examined all possible directions that each surveillance camera could see. Once the direction settings for all cameras were complete, I called a function to check the number of blind spots. If this number was smaller than the current minimum value, I updated the minimum value accordingly.&lt;/p&gt;
&lt;p&gt;Since I tend to add comments immediately after solving a problem, detailed solution methods will be included in the code comments in future posts as well.&lt;/p&gt;
&lt;h3&gt;Solution Code&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;# 감시&lt;/span&gt;

&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; sys

&lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt; = sys.stdin.readline

&lt;span class=&quot;hljs-keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;check_blind_spot&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;matrix: &lt;span class=&quot;hljs-built_in&quot;&gt;list&lt;/span&gt;, y_range: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;, x_range: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;&lt;/span&gt;) -&amp;gt; &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;:
    &lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;&amp;#x27;&amp;#x27;
    현재 사무실 내 사각지대 갯수를 반환하는 함수
    &amp;#x27;&amp;#x27;&amp;#x27;&lt;/span&gt;

    &lt;span class=&quot;hljs-comment&quot;&gt;# 사각지대 변수 선언&lt;/span&gt;
    blind_here = &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;

    &lt;span class=&quot;hljs-comment&quot;&gt;# 모든 좌표에 대해서 조사&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; y_idx &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(y_range):
        &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; x_idx &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(x_range):

            &lt;span class=&quot;hljs-comment&quot;&gt;# 해당 좌표값이 0일 경우만 카운팅&lt;/span&gt;
            &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;not&lt;/span&gt; matrix[y_idx][x_idx]:
                blind_here += &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;

    &lt;span class=&quot;hljs-comment&quot;&gt;# 결과 반환&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; blind_here

&lt;span class=&quot;hljs-comment&quot;&gt;# 사무실 가로 및 세로 크기 입력&lt;/span&gt;
height, width = &lt;span class=&quot;hljs-built_in&quot;&gt;map&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;, &lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt;().split())

&lt;span class=&quot;hljs-comment&quot;&gt;# CCTV 정보 및 사무실 정보를 담을 리스트 선언&lt;/span&gt;
cctvs = []
work_space = []

&lt;span class=&quot;hljs-comment&quot;&gt;# 초기 사각지대 갯수 확인&lt;/span&gt;
blind_spot = &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;

&lt;span class=&quot;hljs-comment&quot;&gt;# 사무실 정보 입력&lt;/span&gt;
&lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; y_idx &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(height):

    &lt;span class=&quot;hljs-comment&quot;&gt;# 행 정보 확인&lt;/span&gt;
    temp = &lt;span class=&quot;hljs-built_in&quot;&gt;list&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;input&lt;/span&gt;().split())

    &lt;span class=&quot;hljs-comment&quot;&gt;# 모든 요소들에 대해 조사&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; x_idx &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(width):

        &lt;span class=&quot;hljs-comment&quot;&gt;# 만약 CCTV가 있다면 리스트에 추가&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; temp[x_idx] &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;12345&amp;#x27;&lt;/span&gt;:
            cctvs.append(((y_idx, x_idx), &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;(temp[x_idx])))

        &lt;span class=&quot;hljs-comment&quot;&gt;# CCTV도 아니고 벽도 아니라면 초기 사각지대&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;:
            &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; temp[x_idx] == &lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;0&amp;#x27;&lt;/span&gt;:
                blind_spot += &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;

    &lt;span class=&quot;hljs-comment&quot;&gt;# 행 정보를 리스트에 추가&lt;/span&gt;
    work_space.append(&lt;span class=&quot;hljs-built_in&quot;&gt;list&lt;/span&gt;(&lt;span class=&quot;hljs-built_in&quot;&gt;map&lt;/span&gt;(&lt;span class=&quot;hljs-keyword&quot;&gt;lambda&lt;/span&gt; x: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;(x), temp)))

&lt;span class=&quot;hljs-comment&quot;&gt;# CCTV 갯수 변수 선언&lt;/span&gt;
cctv_amount = &lt;span class=&quot;hljs-built_in&quot;&gt;len&lt;/span&gt;(cctvs)

&lt;span class=&quot;hljs-comment&quot;&gt;# CCTV 방향 정보 딕셔너리 선언&lt;/span&gt;
cctv_directions = {
    &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;: {&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;: [(&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;)], &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;: [(-&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;)], &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;: [(&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;)], &lt;span class=&quot;hljs-number&quot;&gt;3&lt;/span&gt;: [(&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, -&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;)]},
    &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;: {&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;: [(&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;), (-&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;)], &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;: [(&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;), (&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, -&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;)]},
    &lt;span class=&quot;hljs-number&quot;&gt;3&lt;/span&gt;: {&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;: [(-&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;), (&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;)], &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;: [(&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;), (&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;)], &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;: [(&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;), (&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, -&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;)], &lt;span class=&quot;hljs-number&quot;&gt;3&lt;/span&gt;: [(&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, -&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;), (-&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;)]},
    &lt;span class=&quot;hljs-number&quot;&gt;4&lt;/span&gt;: {&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;: [(-&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;), (&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;), (&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, -&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;)], &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;: [(&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;), (&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;), (&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, -&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;)], &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;: [(&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;), (-&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;), (&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, -&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;)], &lt;span class=&quot;hljs-number&quot;&gt;3&lt;/span&gt;: [(&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;), (-&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;), (&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;)]},
    &lt;span class=&quot;hljs-number&quot;&gt;5&lt;/span&gt;: {&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;: [(&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;), (-&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;), (&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;), (&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, -&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;)]},
}

&lt;span class=&quot;hljs-comment&quot;&gt;# 각 CCTV의 방향 정보를 담은 리스트 선언&lt;/span&gt;
max_direction = [&lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;dummy&amp;#x27;&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;4&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;4&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;4&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;]

&lt;span class=&quot;hljs-comment&quot;&gt;# CCTV가 존재하지 않는 경우 기존 사각지대의 갯수를 출력&lt;/span&gt;
&lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;not&lt;/span&gt; cctv_amount:
    &lt;span class=&quot;hljs-built_in&quot;&gt;print&lt;/span&gt;(blind_spot)

&lt;span class=&quot;hljs-comment&quot;&gt;# 만약 존재한다면 CCTV 방향에 따른 사각지대의 갯수를 조사&lt;/span&gt;
&lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;:

    &lt;span class=&quot;hljs-comment&quot;&gt;# 최종 사각지대 갯수 변수 선언&lt;/span&gt;
    result = blind_spot

    &lt;span class=&quot;hljs-keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;min_blind_spot&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;field: &lt;span class=&quot;hljs-built_in&quot;&gt;list&lt;/span&gt;, cctv_list: &lt;span class=&quot;hljs-built_in&quot;&gt;list&lt;/span&gt;, sight: &lt;span class=&quot;hljs-built_in&quot;&gt;dict&lt;/span&gt;, max_direction: &lt;span class=&quot;hljs-built_in&quot;&gt;list&lt;/span&gt;,
                       now_cctv: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt; = &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, y_range: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt; = height, x_range: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt; = width,
                       limit_cctv: &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt; = cctv_amount&lt;/span&gt;) -&amp;gt; &lt;span class=&quot;hljs-literal&quot;&gt;None&lt;/span&gt;:
        &lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;&amp;#x27;&amp;#x27;
        CCTV를 모두 최적의 상태로 설치할 때 최소 사각지대 갯수를 확인하는 함수
        &amp;#x27;&amp;#x27;&amp;#x27;&lt;/span&gt;

        &lt;span class=&quot;hljs-comment&quot;&gt;# 결과값 전역 변수 등록&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;global&lt;/span&gt; result

        &lt;span class=&quot;hljs-comment&quot;&gt;# Back Tracking&lt;/span&gt;

        &lt;span class=&quot;hljs-comment&quot;&gt;# 모든 CCTV를 전부 확인한 경우&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; now_cctv == limit_cctv:

            &lt;span class=&quot;hljs-comment&quot;&gt;# 현재 사각지대 갯수 확인&lt;/span&gt;
            now_result = check_blind_spot(field, y_range, x_range)

            &lt;span class=&quot;hljs-comment&quot;&gt;# 기존 최소값보다 작은 경우 갱신&lt;/span&gt;
            &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; result &amp;gt; now_result:
                result = now_result

            &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt;

        &lt;span class=&quot;hljs-comment&quot;&gt;# 아직 확인하지 않은 CCTV가 존재하는 경우&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;:

            &lt;span class=&quot;hljs-comment&quot;&gt;# 현재 확인할 CCTV 정보 확인&lt;/span&gt;
            cctv_idx, cctv_type = cctv_list[now_cctv]

            &lt;span class=&quot;hljs-comment&quot;&gt;# 좌표 분리&lt;/span&gt;
            y_cctv, x_cctv = cctv_idx

            &lt;span class=&quot;hljs-comment&quot;&gt;# CCTV에 종류에 따라 감시 방향의 경우의 수만큼 조사&lt;/span&gt;
            &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; direction_code &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;range&lt;/span&gt;(max_direction[cctv_type]):

                &lt;span class=&quot;hljs-comment&quot;&gt;# 현재 주시 방향 확인&lt;/span&gt;
                cctv_directions_now = sight[cctv_type][direction_code]

                &lt;span class=&quot;hljs-comment&quot;&gt;# 해당 주시 방향에서 볼 수 있는 좌표를 담을 리스트 선언&lt;/span&gt;
                now_view = []

                &lt;span class=&quot;hljs-comment&quot;&gt;# 깊이 탐색을 진행할 방향 설정&lt;/span&gt;
                &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; direction &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; cctv_directions_now:

                    &lt;span class=&quot;hljs-comment&quot;&gt;# 이동 방향 좌표 분리&lt;/span&gt;
                    move_y, move_x = direction

                    &lt;span class=&quot;hljs-comment&quot;&gt;# 초기 좌표 설정&lt;/span&gt;
                    now_y, now_x = y_cctv, x_cctv

                    &lt;span class=&quot;hljs-comment&quot;&gt;# 해당 방향에 대해서 반복 조사&lt;/span&gt;
                    &lt;span class=&quot;hljs-keyword&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;hljs-literal&quot;&gt;True&lt;/span&gt;:

                        next_y, next_x = now_y + move_y, now_x + move_x

                        &lt;span class=&quot;hljs-comment&quot;&gt;# 사무실 범위를 벗어나지 않은 경우&lt;/span&gt;
                        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt; &amp;lt;= next_y &amp;lt; y_range &lt;span class=&quot;hljs-keyword&quot;&gt;and&lt;/span&gt; &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt; &amp;lt;= next_x &amp;lt; x_range:

                            &lt;span class=&quot;hljs-comment&quot;&gt;# 벽을 만났다면 반복 종료&lt;/span&gt;
                            &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; field[next_y][next_x] == &lt;span class=&quot;hljs-number&quot;&gt;6&lt;/span&gt;:
                                &lt;span class=&quot;hljs-keyword&quot;&gt;break&lt;/span&gt;

                            &lt;span class=&quot;hljs-comment&quot;&gt;# 벽을 만난 것이 아닐 경우&lt;/span&gt;
                            &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;:

                                &lt;span class=&quot;hljs-comment&quot;&gt;# 해당 좌표가 사각지대일 경우&lt;/span&gt;
                                &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;not&lt;/span&gt; field[next_y][next_x]:

                                    &lt;span class=&quot;hljs-comment&quot;&gt;# 리스트에 기록 후 비사각지대 처리&lt;/span&gt;
                                    now_view.append((next_y, next_x))
                                    field[next_y][next_x] = &lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;#&amp;#x27;&lt;/span&gt;

                                &lt;span class=&quot;hljs-comment&quot;&gt;# 현재 좌표 갱신&lt;/span&gt;
                                now_y, now_x = next_y, next_x

                        &lt;span class=&quot;hljs-comment&quot;&gt;# 사무실 범위를 벗어났다면 반복 종료&lt;/span&gt;
                        &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;:
                            &lt;span class=&quot;hljs-keyword&quot;&gt;break&lt;/span&gt;

                &lt;span class=&quot;hljs-comment&quot;&gt;# 수집한 좌표들을 다음 CCTV에 조사&lt;/span&gt;
                min_blind_spot(field, cctvs, cctv_directions, max_direction, now_cctv + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;)

                &lt;span class=&quot;hljs-comment&quot;&gt;# 초기화&lt;/span&gt;
                &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; y_idx, x_idx &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; now_view:
                    field[y_idx][x_idx] = &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;

    &lt;span class=&quot;hljs-comment&quot;&gt;# 함수를 호출하여 결과 도출&lt;/span&gt;
    min_blind_spot(work_space, cctvs, cctv_directions, max_direction)

    &lt;span class=&quot;hljs-comment&quot;&gt;# 결과값 출력&lt;/span&gt;
    &lt;span class=&quot;hljs-built_in&quot;&gt;print&lt;/span&gt;(result)

&lt;/code&gt;&lt;/pre&gt;
</content:encoded></item><item><title>First Post</title><link>https://www.traceoflight.dev/en/blog/intro/</link><guid isPermaLink="true">https://www.traceoflight.dev/en/blog/intro/</guid><description>Why I Started This Blog</description><pubDate>Sat, 22 Oct 2022 18:26:40 GMT</pubDate><content:encoded>&lt;p&gt;In the past, I used to organize my notes privately, so that only I could see them.&lt;/p&gt;
&lt;p&gt;But then I started wondering if there was really any point in taking the time to organize them neatly if that was the case. After weighing my options—between organizing them neatly and posting them somewhere accessible, or just jotting them down roughly and posting them somewhere accessible—I decided to go with the latter.&lt;/p&gt;
&lt;p&gt;I hope that the material I’ve studied and organized will be helpful not only to me, but also to anyone else who happens to read this.&lt;/p&gt;
</content:encoded></item></channel></rss>