# competitive-programming

Published articles for competitive-programming.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Saving Christmas with Kotlin

DevFeed: [Saving Christmas with Kotlin](<https://devfeed.tech/articles/saving-christmas-with-kotlin-24739.md>)

Original publisher: [Read original article](<https://medium.com/xorum-io/saving-christmas-with-kotlin-e3e239b6fe3d?source=rss----92bb7980cc9f---4>)

Author: Yev Kanivets

Published: 2022-01-29T12:24:13Z

Content type: tutorial

Language: en

Sources: [xorum.io - Medium](<https://devfeed.tech/sources/xorum-io-medium.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Advent of Code](<https://devfeed.tech/topics/advent-of-code.md>), [competitive-programming](<https://devfeed.tech/topics/competitive-programming.md>), [Programming](<https://devfeed.tech/topics/programming.md>)

Tags: [advent-of-code](<https://devfeed.tech/tags/advent-of-code.md>), [algorithms](<https://devfeed.tech/tags/algorithms.md>), [competitive-programming](<https://devfeed.tech/tags/competitive-programming.md>), [data-structures](<https://devfeed.tech/tags/data-structures.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [programming](<https://devfeed.tech/tags/programming.md>)

### AI overview

A developer describes using Kotlin to complete all 50 challenges of Advent of Code 2021 over 25 days and shares links to a four-part series of Kotlin ideas and solutions. The article also discusses Kotlin's suitability for competitive programming.

### Source excerpt

It's been a month since I've saved a Christmas. Now, I feel it's time to tell you exactly how I did it. I wasn't alone, though. My faithful companion was crucial to the success of my mission. Yes, Kotlin, I'm talking about you. But let's return to the day when it all started: I was minding my own business on a ship at sea when the overboard alarm goes off! I rushed to see if I could help. Apparently, one of the Elves tripped and accidentally sent the sleigh keys flying into the ocean!Before I knew it, I was inside a submarine the Elves kept ready for situations like this. It was covered in Christmas lights (because of course it is), and it even had an experimental antenna that should be able to track the keys if I could boost its signal strength high enough; there was a little meter that indicated the antenna's signal strength by displaying 0-50 stars.My instincts told me that in order to save Christmas, I needed to get all fifty stars by December 25th. It turns out that 200K+ other people happened to get into a similar situation. You can still see the complete log of our adventures on this site. Some people call it the "Advent of Code" and say it happens yearly. My way down It took me 25 days and 50 challenges (yeah, two challenges per day) to get those sleigh keys and save the Christmas. Every day at 7 a.m. (UTC+2), we reached a new milestone that unlocked two more challenges to solve. Most of them took from one to two hours to get done. Thank God there was a pretty good Internet connection in my submarine (I could even work remotely and didn't need to take a vacation for such a noble task), so I still had plenty of time to share my ideas and solutions: Ideas and Solutions for Advent of Code 2021 in Kotlin -- Part 1/4 Ideas and Solutions for Advent of Code 2021 in Kotlin -- Part 2/4 Ideas and Solutions for Advent of Code 2021 in Kotlin -- Part 3/4 Ideas and Solutions for Advent of Code 2021 in Kotlin -- Part 4/4 Spending 25 days locked in a submarine and solving chall

## Ideas and Solutions for Advent of Code 2021 in Kotlin -- Part 4/4

DevFeed: [Ideas and Solutions for Advent of Code 2021 in Kotlin -- Part 4/4](<https://devfeed.tech/articles/ideas-and-solutions-for-advent-of-code-2021-in-kotlin-part-4-4-24736.md>)

Original publisher: [Read original article](<https://medium.com/xorum-io/ideas-and-solutions-for-advent-of-code-2021-in-kotlin-part-4-4-75c207692bdb?source=rss----92bb7980cc9f---4>)

Author: Yev Kanivets

Published: 2021-12-26T14:39:41Z

Content type: tutorial

Language: en

Sources: [xorum.io - Medium](<https://devfeed.tech/sources/xorum-io-medium.md>)

Topics: [Advent of Code](<https://devfeed.tech/topics/advent-of-code.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [3D](<https://devfeed.tech/topics/3d.md>), [pixel](<https://devfeed.tech/topics/pixel.md>)

Tags: [3d](<https://devfeed.tech/tags/3d.md>), [advent-of-code](<https://devfeed.tech/tags/advent-of-code.md>), [algorithms](<https://devfeed.tech/tags/algorithms.md>), [array](<https://devfeed.tech/tags/array.md>), [beacon](<https://devfeed.tech/tags/beacon.md>), [competitive-programming](<https://devfeed.tech/tags/competitive-programming.md>), [data-structures](<https://devfeed.tech/tags/data-structures.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [pixel](<https://devfeed.tech/tags/pixel.md>), [points](<https://devfeed.tech/tags/points.md>), [scanner](<https://devfeed.tech/tags/scanner.md>), [solutions](<https://devfeed.tech/tags/solutions.md>)

### AI overview

A Kotlin walkthrough of Advent of Code 2021 tasks 19 and 20. It explains matching rotated point sets in 3D space using beacon intersections, then enhancing an image represented as a 2D pixel array while accounting for infinite padding and changing background values.

### Source excerpt

Ideas and Solutions for Advent of Code 2021 in Kotlin -- Part 4/4 The final week of Advent of Code was, obviously, the most challenging one. To be honest I was close to being happy with just a silver star multiple times. But at the end, tenacity made the difference. 50 stars are mine this year 🌟 Ideas and Solutions for tasks 1 to 6 can be found here, for tasks 7 to 12 -- here, for tasks 13 to 18 -- here. Day 19: Beacon Scanner We are provided with several sets of points in 3D space. Those points are rotated differently in each set, so we don't know how X, Y, and Z coordinates are aligned between sets. Our goal is to merge all those sets into a single group by matching points (sub-task one) and find the most significant distance between coordinate origins after they are matched. Here is the complete task. This is an exciting task! I've initially learned about this idea from The Three-Body Problem book, which introduced the concept of locating any star in the Universe by the distances from a few nearest stars -- in our case, "a few" means 12. Think about it as a star fingerprint ;) So to match the sets of points in 3D space, we need: check all combinations of rotations in three dimensions (in our task, the step is 90 degrees, so there are 48 combinations) for the whole set assume that each pair of points from the first set and the second set is an intersection by adjusting all points to that pair check how many adjusted points intersect between the two sets if there are more than 12 intersections, voilá -- the sets are matched The embedded Kotlin's functions like intersect, map, and mapNotNull make the solution, even for such a complex task, elegant. Day 20: Trench Map This image-enhancing task provides us with the initial photo (2D array of black and white pixels), and enhancing guidance (1D array). Enhancing happens in steps, where for each pixel, we found its enhanced value as a result of a combination of itself + all eight adjacent pixels. Here is the complete task. We

## Ideas and Solutions for Advent of Code 2021 in Kotlin -- Part 3/4

DevFeed: [Ideas and Solutions for Advent of Code 2021 in Kotlin -- Part 3/4](<https://devfeed.tech/articles/ideas-and-solutions-for-advent-of-code-2021-in-kotlin-part-3-4-24735.md>)

Original publisher: [Read original article](<https://medium.com/xorum-io/ideas-and-solutions-for-advent-of-code-2021-in-kotlin-part-3-4-dbfd577703cc?source=rss----92bb7980cc9f---4>)

Author: Yev Kanivets

Published: 2021-12-26T14:22:49Z

Content type: tutorial

Language: en

Sources: [xorum.io - Medium](<https://devfeed.tech/sources/xorum-io-medium.md>)

Topics: [Advent of Code](<https://devfeed.tech/topics/advent-of-code.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [competitive-programming](<https://devfeed.tech/topics/competitive-programming.md>), [Graphs](<https://devfeed.tech/topics/graphs.md>), [math](<https://devfeed.tech/topics/math.md>)

Tags: [advent-of-code](<https://devfeed.tech/tags/advent-of-code.md>), [algorithms](<https://devfeed.tech/tags/algorithms.md>), [array](<https://devfeed.tech/tags/array.md>), [code](<https://devfeed.tech/tags/code.md>), [competitive-programming](<https://devfeed.tech/tags/competitive-programming.md>), [data-structures](<https://devfeed.tech/tags/data-structures.md>), [graph-theory](<https://devfeed.tech/tags/graph-theory.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [memory](<https://devfeed.tech/tags/memory.md>), [pairs](<https://devfeed.tech/tags/pairs.md>), [programming](<https://devfeed.tech/tags/programming.md>), [solutions](<https://devfeed.tech/tags/solutions.md>), [time](<https://devfeed.tech/tags/time.md>)

### AI overview

This article presents high-level ideas and Kotlin solutions for Advent of Code 2021 tasks from days 13 to 15. It discusses folding a 2D array, modeling polymer growth with dynamic programming, and finding a shortest path in a 2D array.

### Source excerpt

Ideas and Solutions for Advent of Code 2021 in Kotlin -- Part 3/4 The third week of Advent of Code requires more time and even some competitive programming knowledge like dynamic programming and graph theory. In this article, I share some high-level ideas and my solutions if you need a hint or a few to get that gold star. Ideas and Solutions for tasks 1 to 6 can be found here, for tasks 7 to 12 -- here. Day 13: Transparent Origami The 2D array contains two types of symbols -- . and #. This array can be folded horizontally and vertically multiple times. When folding # symbols replace . symbols, but not vice versa. Here is the complete task. This is a modeling task, which you can do on the 2D array itself, but the possible range is quite large, so you can hit a memory limit. The smarter solution would be to fold the # symbols (the initial input, actually). Such folding can be done with Kotlin's fold function using the initial value of # symbol positions and mapNotNull, which mirrors X or Y coordinates depending on the fold direction. Here is my solution. Day 14: Extended Polymerization We get the initial string (template) consisting of uppercase letters, which describe the initial state of the polymer. The list of pair insertion rules allows growing the initial polymer step by step exponentially. We need to model this growth during 10 (first sub-task) and 40 (second sub-task) steps. Here is the complete task. The first sub-task can be solved just by modeling, but even 20 steps are too long and require too much memory and time. The (much) better solution is based on dynamic programming. You can easily see that every pair grows independently of others (new elements are always added inside the pair). It means that the solution can be found for each pair separately and then combined. It doesn't speed up things sufficiently though. But makes the solution easier? Yes. Now, let's grow each pair step by step. So at each step, every pair (usually) produces two more pairs, which h

## Ideas and Solutions for Advent of Code 2021 in Kotlin -- Part 1/4

DevFeed: [Ideas and Solutions for Advent of Code 2021 in Kotlin -- Part 1/4](<https://devfeed.tech/articles/ideas-and-solutions-for-advent-of-code-2021-in-kotlin-part-1-4-24733.md>)

Original publisher: [Read original article](<https://medium.com/xorum-io/ideas-and-solutions-for-advent-of-code-2021-in-kotlin-part-1-4-9a16d9e3bd57?source=rss----92bb7980cc9f---4>)

Author: Yev Kanivets

Published: 2021-12-13T15:31:55Z

Content type: tutorial

Language: en

Sources: [xorum.io - Medium](<https://devfeed.tech/sources/xorum-io-medium.md>)

Topics: [Advent of Code](<https://devfeed.tech/topics/advent-of-code.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [advent-of-code](<https://devfeed.tech/tags/advent-of-code.md>), [algorithms](<https://devfeed.tech/tags/algorithms.md>), [array](<https://devfeed.tech/tags/array.md>), [commands](<https://devfeed.tech/tags/commands.md>), [competitive-programming](<https://devfeed.tech/tags/competitive-programming.md>), [data-structures](<https://devfeed.tech/tags/data-structures.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [map](<https://devfeed.tech/tags/map.md>), [programming](<https://devfeed.tech/tags/programming.md>), [solutions](<https://devfeed.tech/tags/solutions.md>)

### AI overview

A Kotlin-focused walkthrough of the first six Advent of Code 2021 puzzles. It explains the key solution ideas for the early tasks, including array comparisons, submarine movement modeling, and binary-number calculations, while linking to source code for further guidance.

### Source excerpt

Ideas and Solutions for Advent of Code 2021 in Kotlin -- Part 1/4 There are so many things to do before Christmas, so I was always wondering how people find extra time to solve a daily programming puzzle of Advent of Code. Well, this year I'm one of those lucky folks with a bunch of spare time. Advent of Code is an annual event of Christmas-oriented programming challenges started December 2015. Every year since then, on the first day of December, a programming puzzle is published every day for twenty-four days. You can solve the puzzle and provide an answer using the language of your choice. Extra reason by JetBrains in the form of the giveaway of some Kotlin care packages has certainly contributed to my motivation. But what's the point of solving tasks without sharing your ideas and solutions with the community ;) So here we are, the first six tasks. What's special about this article? I won't be sharing the complete editorial, but the key idea only, so you can still solve the task by yourself. And if you need more guidance, there is a source code linked. Day 1: Sonar Sweep We are given an array of heights of a seafloor. We need to calculate the number of times heights (sub-task one) and sliding triples of heights (sub-task two) are increasing. Complete task is here. To solve both tasks we need to go from left to right and compare the previous element (or sliding triple) to the current one. That's pretty simple, but challenge yourself to craft the beautiful code. In Kotlin we may consider using drop and foldIndexed functions for this. Here is my solution. Day 2: Dive! The submarine can move in 2D space (horizontal position and depth) controlled by the set of commands. Moves mechanics are slightly different between subtasks, but the overall approach and goal are the same -- model moves and find the resulting position. Complete task is here. The first sub-task can be solved by folding horizontal position and depth changes, but the second sub-task should be modeled exact

## Competitive Programming: Benefits, Career Value, and Criticism

DevFeed: [Competitive Programming: Benefits, Career Value, and Criticism](<https://devfeed.tech/articles/to-cp-or-not-to-cp-25683.md>)

Original publisher: [Read original article](<https://blog.sanskar10100.dev/to-cp-or-not-to-cp>)

Author: Sanskar Agrawal

Published: 2021-11-14T13:29:40Z

Content type: opinion

Language: en

Sources: [Sanskar's Stuff](<https://devfeed.tech/sources/sanskar-s-stuff.md>)

Topics: [Programming](<https://devfeed.tech/topics/programming.md>), [coding](<https://devfeed.tech/topics/coding.md>), [Software](<https://devfeed.tech/topics/software.md>)

Tags: [career](<https://devfeed.tech/tags/career.md>), [coding](<https://devfeed.tech/tags/coding.md>), [competitive-programming](<https://devfeed.tech/tags/competitive-programming.md>), [opinion](<https://devfeed.tech/tags/opinion.md>), [programming](<https://devfeed.tech/tags/programming.md>)

### AI overview

The author presents competitive programming as a puzzle-like activity that develops fast problem-solving under constraints and may help with recruiting. The article also discusses criticism of competitive programming, including coding habits that may not reflect software engineering, and notes alternative paths such as building apps or contributing to open source.

### Source excerpt

Before we start, I'd like to clarify where I'm coming from. I like Nikola Tesla, Guido van Rossum and Steve Wozniak. Money is important, but it's not as important as doing good engineering. How is this relevant? I want you to know where I'm coming fr...