<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Aynur Zulkarnaev on Medium]]></title>
        <description><![CDATA[Stories by Aynur Zulkarnaev on Medium]]></description>
        <link>https://medium.com/@reuo?source=rss-1674b625550d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*dM8gEW63pnYdZRNs.jpg</url>
            <title>Stories by Aynur Zulkarnaev on Medium</title>
            <link>https://medium.com/@reuo?source=rss-1674b625550d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 20:45:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@reuo/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Go Quiz: Test your knowledge of the programming language]]></title>
            <link>https://medium.com/inside-sumup/go-quiz-test-your-knowledge-of-the-programming-language-b818428c1bc3?source=rss-1674b625550d------2</link>
            <guid isPermaLink="false">https://medium.com/p/b818428c1bc3</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[quiz]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Aynur Zulkarnaev]]></dc:creator>
            <pubDate>Tue, 25 May 2021 16:25:02 GMT</pubDate>
            <atom:updated>2021-05-25T16:25:02.344Z</atom:updated>
            <content:encoded><![CDATA[<p>Have you mastered Golang? Why not test your knowledge by taking this quiz! In it, we’ll be investigating interesting aspects and corner cases of Golang. While the answers to some questions will appear obvious, others will require you to take a closer look — even for the most experienced Go developers. By the end of this article, we hope you’ll have gained a deeper understanding of the programming language and its underlying philosophy.</p><figure><img alt="Aynur Zulkarnaev SumUp Golang Quiz" src="https://cdn-images-1.medium.com/max/706/1*P410Hv6jsH8n_V6LbDNnKQ.png" /><figcaption>Aynur Zulkarnaev: Quizmaster and Engineer at SumUp</figcaption></figure><p>So without further ado, let’s get started!</p><h3>Value assignment</h3><p><strong>1. What value </strong><strong>y will have at the end of the execution?</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fa4cf2e13e509b6f922eb2c348a04293/href">https://medium.com/media/fa4cf2e13e509b6f922eb2c348a04293/href</a></iframe><p>According to the specification, for loop creates its own scope. Therefore, we are dealing with two different scopes there: one insidemain function, and one inside the for loop. Therefore, we don&#39;t reassign y inside the for loop initialization, but instead creating a new y that shadows the one from the outer scope. Therefore, outer y is not affected, and the program will output 0.</p><h3>A part of a string</h3><p>In this example, we have a string and would like to access a part of it.</p><p><strong>2. What would be the result of the following snippet?</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8b61cc5bbed107b36dcd12cf5dadc5f5/href">https://medium.com/media/8b61cc5bbed107b36dcd12cf5dadc5f5/href</a></iframe><p>The first two print statement would output the same result. A string in Golang is an immutable array of bytes and every character is encoded in UTF-8. In this case, we are dealing with the ASCII-only string, therefore, character 9 will be encoded as a single byte with a value equal to 57. Therefore, the first print statement would output 57. Exactly the same value would be printed at the second line, as in this case, we will have rune r that consists of a single byte.</p><p>However, the program won’t compile due to the third line, as we are dealing with different types: uint8 (under alias byte) and int32 (under alias rune). The numeric value of the variables is equal, but their types are different, therefore, they cannot be compared without the explicit type conversion.</p><h3>Struct Conversion</h3><p>In this example, we have two similar structs that differ only in struct tags. Such an approach could be used in a real life. For example, you can have a separate representation of a single domain model in different packages: package db that is responsible for database persistence and package api that is responsible for handling the incoming requests. In this case, the structs would be equal save for the struct tags.</p><p><strong>3. What would be the result of the following code snippet?</strong></p><p>#v outputs the full Golang representation of the value, including the type of the struct and its field names.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/be2f7b1c92b178bae5b6e5ff47ae14b3/href">https://medium.com/media/be2f7b1c92b178bae5b6e5ff47ae14b3/href</a></iframe><p>That’s a tricky question because according to the Golang specification a struct tag is a part of the struct definition. Therefore, at some point, it wasn’t possible to do the conversion. However, later the Go team decided to relax the constraint (without changing the definition of the struct in the spec), and now such conversion is permitted.</p><p>main.Struct2{A:1}</p><p><strong>4. How about this snippet? We are trying to convert </strong><strong>Struct1 to </strong><strong>Struct2. All information necessary for </strong><strong>Struct2 is available in </strong><strong>Struct1. However, there is also a redundant field </strong><strong>B in </strong><strong>Struct1.</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d1212c2ecffa4f096aac7433d89c9de6/href">https://medium.com/media/d1212c2ecffa4f096aac7433d89c9de6/href</a></iframe><p>In this case, the specification does not care whether we have all the information to instantiate Struct2 from Struct1. Struct1 has an extra field, and that&#39;s the end of the deal: the operation is not permitted, and the code won&#39;t compile.</p><h3>JSON Unmarshalling</h3><p><strong>5. Will the existing records in the map be preserved when we unmarshal JSON-encoded values into it? What happens in the case of a collision (note key </strong><strong>Field1)?</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/352fc9d60fc87ff65db3556cc1b79322/href">https://medium.com/media/352fc9d60fc87ff65db3556cc1b79322/href</a></iframe><p>Existing records in the map will be preserved. In the case of a collision, the value will be overwritten.</p><p>map[Field1:1 Field2:202]</p><p><strong>6. What about structs?</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cd9ad5f67551daf1f069f995fedd7c55/href">https://medium.com/media/cd9ad5f67551daf1f069f995fedd7c55/href</a></iframe><p>The same logic is valid here:</p><p>{Field1:1 Field2:202}</p><p><strong>And that all the question for today. How many right answers did you get out of six?</strong></p><p>From my personal point of view, one of the main advantages of working is SumUp is the abundance of opportunities to Grow. As a developer in SumUp, I can use my own personal budget, spend every other Friday as a hack day and participate in various engineering discussions inside the whole company. The article above was initially presented as a quiz in one of the regular internal meetings — Engineering Sync of my tribe.</p><p>If you’re interested in working as a Golang Engineer, we have an open <a href="https://grnh.se/c3e2b1b92us">position</a> (and some more engineering positions <a href="https://grnh.se/abb515b52us">here</a>). Prior knowledge of Golang is not required. Keep in mind, I’m not a recruiter, but I can share my personal experience as a Backend Engineer working at SumUp.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b818428c1bc3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/inside-sumup/go-quiz-test-your-knowledge-of-the-programming-language-b818428c1bc3">Go Quiz: Test your knowledge of the programming language</a> was originally published in <a href="https://medium.com/inside-sumup">Inside SumUp</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Algorithms in Go: Dutch National Flag]]></title>
            <link>https://medium.com/inside-sumup/algorithms-in-go-dutch-national-flag-1050860c42bf?source=rss-1674b625550d------2</link>
            <guid isPermaLink="false">https://medium.com/p/1050860c42bf</guid>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[go]]></category>
            <dc:creator><![CDATA[Aynur Zulkarnaev]]></dc:creator>
            <pubDate>Thu, 25 Mar 2021 12:16:09 GMT</pubDate>
            <atom:updated>2021-03-30T07:30:41.955Z</atom:updated>
            <content:encoded><![CDATA[<h3>Algorithms in Go: Our path to solving the Dutch National Flag problem</h3><p>Backend Engineer, Aynur Zulkarnaev, shares how his team solved one of the most popular algorithmic patterns, Dutch National Flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vaJTR-tCEPsBisfLco_rCQ.png" /><figcaption>Aynur Zulkarnaev, Backend Engineer Golang</figcaption></figure><p>Most solutions to algorithmic problems can be grouped into a rather small number of patterns. Before we can start to solve some of them, we need to think about how we can classify them. For example, can we apply a <em>fast and slow</em> аlgorithmic pattern or do we need to use a <em>cyclic sort pattern</em>? Some problems can have several solutions based on different patterns. It can easily become quite complex. In this <a href="https://habr.com/en/post/545986/">series</a>, we discuss the most popular algorithmic patterns that cover more than 90% of the usual problems we see.</p><p>Let’s start by saying that we aren’t going to be talking about the problems from your high school algorithm 101 course. This solution is not intended to cover things like the Karatsuba (fast multiplication) algorithm or prove different methods of sorting.</p><p>Instead, we’re going to look at algorithmic patterns focused on practical skills needed for the solution to common problems. For example, when we set up a Prometheus alert for high request latency, we’re dealing with the <a href="https://habr.com/en/post/531444/">Sliding Window pattern</a>. Or let’s say we organise a team event and need to find an available time slot for every participant. At the first glance, it’s not so obvious that in doing so, we‘re actually solving an <a href="https://habr.com/en/post/538888/">algorithmic</a> problem. In fact, we’re actually solving a bunch of algorithmic problems throughout our daily lives, without even realising it.</p><p>That said, it’s the knowledge about algorithmic patterns that helps one to classify a problem and then apply the appropriate method.</p><p>Most importantly, understanding algorithmic patterns help to boost general programming skills. It’s especially useful when we need to debug some production code, as it trains us to understand the execution flow.</p><p><strong>The Dutch National Flag Problem</strong></p><p>The flag of the Netherlands consists of three colours: red, white and blue. Given balls of these three colours arranged randomly in a line (it does not matter how many balls there are), the task is to arrange them such that all balls of the same colour are together and their collective colour groups are in the correct order.</p><p><strong>The path to the solution</strong></p><p>For simplicity instead of colours red, white, and blue we’ll be dealing with ones, twos and zeroes.</p><p>Let’s start by using our own intuition. We have a collection of zeroes, ones and twos. How can we sort it? Well, one option would be to segment by type, putting aside all zeroesinto a bucket, all onesinto another bucket and all twosinto a third. Then, we could fetch and restore all items bucket by bucket, which would leave us with a single organised collection. This approach works perfectly fine and has great performance. It ensures that we touch all the elements both when putting them in and taking them out of the bucket. So, the overall time complexity is O(n) + O(n) ~= O(n). The space complexity is also O(n) as we need to store all items in the buckets.</p><p>Great, a solution! But, can we do better than that? While there’s no way to improve our time complexity, there is a more efficient algorithm in regard to space complexity. For this, we need to think about how we’d solve the problem <strong>without</strong> the additional buckets. Meaning, how we could solve the problem in-place.</p><p>Let’s take a <strong>leap of faith</strong> and pretend that somehow we were able to process a part of the array. We iterate through part of the array and put encountered zeroes and ones at the beginning of the array and twos at the end of the array. Now, we switched to the next index i with some unprocessed value x. What should we do there?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FhvrZd7hEIZc9Cn7" /></figure><p>In this case, there are three possibilities: x could be equal to 0, 1 or 2.</p><p>Let’s say x is equal to 28. Where should we put it? We already have some twos at the end of the array, so we need to put the current two right before the start of the known twos. We don&#39;t know which value is located before the start of the known twos. Let&#39;s call this value y.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iLzzvoP-SejqySkB" /></figure><p>We swap our current value with y. As we don&#39;t know the value y at our current index i, it’s possible that we need to swap it once more. So we don&#39;t proceed to the next value. For example, we don&#39;t increase our running pointer i. After this operation, we’re left something that looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*necPpsZdD1tYYsKO" /></figure><p>As we now have an additionaltwo at the end of the cadence, we need to shift the start of the known twos. This fact tells us that we need to have one more pointer that indicates the start of the processed twos. Let&#39;s denote this pointer as high. When we encounter another two, we’ll put it right before this pointer.</p><p>Now, let’s consider the case when x is equal to zero. We need to put this zeroright after the last processed zero.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IYVjUc0zz0uvNfZi" /></figure><p>After this operation, we need to shift the end of known zeroes to the right. Therefore, we’ll have another pointer, low, that signifies the end of known zeroes. When we encounter another zero, we’ll place it to the right of this pointer.</p><p>We swap the items at indexesi and low+1. As index low+1 goes directly after the index low that denotes the end of zeroes, the value at index low+1 will always be equal to one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yfn7YQ_rLac2UjLu" /></figure><p>Now, what do we do with ones? That’s a tricky part because, actually, we do nothing. The item is already in place, so we’re free to proceed to the next item.</p><p>Ok, this solution could work when we’re in the <strong>middle </strong>of the processing.<strong> But how do we start?</strong></p><p>The running pointer starts with a value equal to zero. We don’t have any known twos yet, so the start of twos is equal to the length of the array. In this way, the first encountered two will be put at the very end of the array which seems logical. We don&#39;t have any known zeroes either, so the end of zeroes is equal to minus one. Therefore, the first encountered zero will be put at the very beginning of the array and that&#39;s exactly what we want.</p><p>Right, how do we know where should we stop? We could iterate through the whole array, but at some point the movement becomes redundant. When our running pointer becomes equal to high, we know for sure that the value at that index is equal to two and we have already processed it. Therefore, we can stop there. If we don&#39;t have any twos then the value of highis equal to the length of the array, and we stop at the last item.</p><p>Finally, we can implement the algorithm in Go:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4be0525c0b13ba8aabaf103c36504ee2/href">https://medium.com/media/4be0525c0b13ba8aabaf103c36504ee2/href</a></iframe><p>If you’re interested in working as a Backend Engineer, there’s an open <a href="https://grnh.se/c3e2b1b92us">position</a> in my tea (and some more in the <a href="https://sumup.com/careers/positions/?department=Engineering">company</a>). Prior knowledge of Golang is not required. Keep in mind, I’m not a recruiter, but I can share my personal experience as a Backend Engineer working at SumUp.</p><p>Want to read more about algorithmic patterns such as <a href="https://habr.com/en/post/531444/">Sliding Window</a> or <a href="https://habr.com/en/post/545980/">Iterative Postorder Traversal</a>? Follow Aynur’s series: <a href="https://habr.com/en/post/545986/">Algorithms in Go.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1050860c42bf" width="1" height="1" alt=""><hr><p><a href="https://medium.com/inside-sumup/algorithms-in-go-dutch-national-flag-1050860c42bf">Algorithms in Go: Dutch National Flag</a> was originally published in <a href="https://medium.com/inside-sumup">Inside SumUp</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>