<?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 Teiva Harsanyi on Medium]]></title>
        <description><![CDATA[Stories by Teiva Harsanyi on Medium]]></description>
        <link>https://medium.com/@teivah?source=rss-1c96b0f1c413------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ZopHL1godRMHLAmCAQrJxQ.png</url>
            <title>Stories by Teiva Harsanyi on Medium</title>
            <link>https://medium.com/@teivah?source=rss-1c96b0f1c413------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 06 Jun 2026 07:39:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@teivah/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[Moving from Medium to The Coder Cafe]]></title>
            <link>https://teivah.medium.com/moving-from-medium-to-the-coder-cafe-4dd95578b204?source=rss-1c96b0f1c413------2</link>
            <guid isPermaLink="false">https://medium.com/p/4dd95578b204</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[community]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Teiva Harsanyi]]></dc:creator>
            <pubDate>Wed, 12 Mar 2025 15:20:21 GMT</pubDate>
            <atom:updated>2025-03-12T16:17:05.336Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello everyone!</p><p>Just a quick update: I’m transitioning fully from Medium to my free newsletter: <em>The Coder Cafe</em>. Nothing against Medium (kinda), but I want to build a community, and Substack gives me better tools to do that.</p><p>If you’ve enjoyed my content, I’d love for you to join me at <a href="https://thecoder.cafe/?rd=medium.com">thecoder.cafe</a>. I’ll be sharing content there regularly and I’m excited about the opportunities ahead.</p><p>See you there!</p><p>Teiva</p><figure><a href="https://thecoder.cafe/?rd=medium.com"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hItvOyj_g2cOl745s5qdNg.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4dd95578b204" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A 2023 Retrospective]]></title>
            <link>https://teivah.medium.com/a-2023-retrospective-68b9014c5357?source=rss-1c96b0f1c413------2</link>
            <guid isPermaLink="false">https://medium.com/p/68b9014c5357</guid>
            <category><![CDATA[sre]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[advent-of-code]]></category>
            <category><![CDATA[google]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Teiva Harsanyi]]></dc:creator>
            <pubDate>Thu, 21 Dec 2023 20:46:22 GMT</pubDate>
            <atom:updated>2023-12-25T21:17:04.361Z</atom:updated>
            <content:encoded><![CDATA[<p><em>For whom it may interest, my retrospective of 2023.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_opoCOiqz_dKykqYP3CURw.jpeg" /></figure><h3>Professional Situation</h3><p>First things first, I left Docker 🐳.</p><p>When I took the decision to leave my previous company, I applied to both Docker and Google. I had an immediate answer from Docker; I passed the interviews and got an offer. Meanwhile, there was silence from Google. So, I ended up accepting Docker’s offer, and I was happy with it.</p><p>Yet, on my very first day at Docker, who do I get a response from? Google.</p><p>At first, I’m about to reply “<em>Sorry, but I have already found a job</em>”. Yet, I couldn’t bring myself to do it. Working at Google has always been a dream of mine. As a student, I was really horrific and I had nothing but awful grades. So, even the simple idea of me applying to Google was just absurd to me. However, a friend shared his experience going through Google’s interview process for an internship, it felt wonderful, and it planted a <strong>seed</strong> in my mind.</p><p>Five years later, I applied to Google but was rejected during the very first technical interview. So when I received the Google email, I couldn’t ignore it. This time, things went well, and I got a yes from Google.</p><p>So, I left Docker, and it was not easy. I felt terrible leaving after less than a year. The main reason is that I started to get really attached to this company. I met a lot of folks, be it online or during offline events, and most of the time, I was in front of talented <strong>and</strong> modest people—Jackie, Silvin, Nicolas, Sergio, Chaimaa, David, Felipe, Alyx, Guillaume, Djordje, and many more.</p><p>Also, it’s not often you see a CEO who moves from table to table during a company event to chat and have a drink with most of the employees. Perhaps to some people, it might seem basic, but to me, sharing a beer with <a href="https://twitter.com/scottcjohnston">Scott</a> is part of the <em>basic</em> things that made Docker so <strong>special</strong> to me.</p><p>So yes, I left Docker, but it’s no coincidence that Moby still sits on my desk.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*660W5ci9OAcDv9kYSsOLqA.jpeg" /></figure><p>We are in March, and I joined Google as an SRE.</p><p>Before joining Google, I remember thinking, “<em>Wow, it’s going to be crazy</em>”. To be honest, it went even <strong>beyond</strong> that. The scale, the people, the systems, the complexity—everything is just beyond imagination. I’ll write a post for my first anniversary in March to share more about my experience.</p><p>Last, I’m thrilled to have switched to an SRE role. After years as a software engineer, my career took a new direction in 2020 when I started to read <a href="https://sre.google/books/">Google’s SRE books</a>. Since that day, I have become increasingly fascinated by reliability topics. So, how could I say no to the company that celebrated last October <strong>20 years of SRE</strong>?</p><h3>Solving Online Technical Challenges</h3><p>I don’t know about you, but personally, I always worked on algorithms and data structures to prepare coding interviews. For example, to prepare for Google, I tackled a lot of <a href="https://leetcode.com/">Leetcode</a> problems. Therefore, because it was an <strong>obligation</strong> (to have a chance during my interviews), I never really enjoyed it.</p><p>I completely changed my mind thanks to the <a href="https://adventofcode.com/"><strong>Advent of Code</strong></a> (AoC). AoC is an advent calendar of programming puzzles. Every year since 2015, a new puzzle is released each day of December until day 25.</p><p>End of 2022, I completed an AoC for the first time and had immense fun. I enjoyed the feeling of having to tackle seemingly impossible problems. Actually, I had so much fun that I went, “<em>How about doing all the years since 2015?</em>”. And that became an <strong>obsession</strong> for me. As soon as I was finishing my working day, my number one priority was solving a new problem!</p><p>I started AoC 2015 on January 6th and completed all the puzzles up to AoC 2021 by February 14th. In total, 350 stars in 39 days (I told you I was obsessed).</p><p>This experience, which I shared on my <a href="https://medium.com/r?url=https%3A%2F%2Fteivah.medium.com%2Fadvent-of-code-b5bf35a6d115">blog</a>, was fantastic. More than a learning experience, it was the thing that genuinely made me love algorithm and data structure topics.</p><p>I also came across another type of technical challenge, this time on distributed systems: <a href="https://fly.io/dist-sys/">Gossip Glomers</a>. Created by <a href="https://fly.io/">Fly.io</a> and Kyle Kingsbury (the author of <a href="https://jepsen.io/">Jepsen</a>), it involved problems like implementing a broadcast protocol, a Kafka-style log, or a distributed counter. Sure, It was less time-consuming than AoC, but really enriching. If you are interested in distributed systems, I highly recommend it (check out my GitHub repo: <a href="https://github.com/teivah/gossip-glomers">teivah/gossip-glomers</a>).</p><h3>What Else?</h3><p>Striving to improve continuously remained my motto.</p><p>It can sound cliché, but if there’s really one life philosophy that I live by, be it at work or in my personal life is 改善 (<strong>Kaizen</strong>, <em>change for better</em>). In a nutshell, it’s not important how fast you can be; what’s essential is to improve week in and week out. Perhaps it’s the reason why I love the whole domain of computer science so much. Regardless of where you‘re at, there’s always more to learn.</p><p>This year, much of my cognitive effort was devoted to learning about some Google stuff and the SRE role. Nonetheless, I still spent some of my free time exploring new areas, like Python, Vim, and plenty of cool algorithmic topics (e.g., reading the book <a href="https://www.goodreads.com/book/show/52362532-advanced-algorithms-and-data-structures">Advanced Algorithms and Data Structures</a>).</p><p>I also created a (private) place to manage <strong>postmortems</strong> when I’m making significant mistakes—those with a notable impact or recurring ones. In there, I keep track of each mistake, the context surrounding it, the impact it had, the lessons learned I learned, and the number of occurrences I made the same mistake.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wbUKi2tLp0v0M64omvlcHQ.png" /></figure><p>Managing a library of custom postmortems based on your personal mistakes is a strategy I highly recommend. There’s nothing more frustrating than repeating the same mistakes.</p><p>Additionally, this year, I gave my first <strong>offline</strong> talk. I had already presented at conferences before, but only online. My first in-person talk was at the <a href="https://www.meetup.com/fr-FR/golang-paris/">Golang Paris</a> meetup (alongside the great <a href="https://medium.com/u/5c7fb9360a28">Val Deleplace</a>). Despite the initial stress, I really enjoyed it and had a similar experience at <a href="https://www.meetup.com/fr-FR/site-reliability-engineering-france/">SRE France</a>. I also spoke at <a href="https://www.p99conf.io/">P99</a> this year but it was online.</p><p>Next year, one of my main priorities will be to give more offline talks and improve my public speaking and presentation skills. Next stop at <a href="https://confoo.ca/">ConFoo</a> in Montreal in February 2024.</p><h3>Bonus</h3><ul><li>I switched my keyboard layout from azerty to qwerty for better compatibility with Vim (it was a challenging transition after decades of habit!).</li><li>I released <a href="https://100go.co/">100go.co</a>, an online and refined version of my book <a href="https://www.manning.com/books/100-go-mistakes-and-how-to-avoid-them">100 Go Mistakes</a>.</li><li>I only wrote a few blog posts this year: one about <a href="https://teivah.medium.com/advent-of-code-b5bf35a6d115">my AoC experience</a>, another one on <a href="https://teivah.medium.com/probabilistic-increment-4aa2ff64b42">a probabilistic solution in large-scale systems</a>, and one discussing how <a href="https://teivah.medium.com/post-hoc-ergo-propter-hoc-d33878661d44">temporality ≠ causality</a>.</li><li>I published an opinionated <a href="https://github.com/teivah/sre-roadmap">roadmap</a> to becoming an SRE.</li><li>I had the chance to make a <a href="https://www.youtube.com/watch?v=RdQMjTgAfDs">podcast</a> with the goat itself, <a href="https://twitter.com/goinggodotnet">Bill Kennedy</a>.</li><li>I met many amazing people, including <a href="https://medium.com/u/2a2a5f79f252">Pratim Bhosale</a>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FGADWNiOy2fHV6XZVTRLSg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/192/1*d18s_T_xsfALyEqrISlsjQ.png" /></figure><p>Thanks for reading; I wish you the best for 2024 🌟.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=68b9014c5357" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Completed All 8 Advents of Code in One Go: Here Are the Lessons I Learned.]]></title>
            <link>https://teivah.medium.com/advent-of-code-b5bf35a6d115?source=rss-1c96b0f1c413------2</link>
            <guid isPermaLink="false">https://medium.com/p/b5bf35a6d115</guid>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[leetcode]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[advent-of-code]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Teiva Harsanyi]]></dc:creator>
            <pubDate>Wed, 15 Feb 2023 15:14:00 GMT</pubDate>
            <atom:updated>2025-01-20T08:57:11.523Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bFpZgO24dMNSDxV9sN6cvg.png" /></figure><h3>Context</h3><p>Last December, I completed my first <a href="https://adventofcode.com/">Advent Of Code</a>: 2022. Before that, I had a total of something like six stars for the past seven years. But this year, we created a private leaderboard at Docker, and it motivated me to go as far as possible.</p><p>For those unfamiliar with the Advent Of Code, one small word: it’s an advent calendar of programming puzzles. Every year since 2015, <a href="http://was.tl/">Eric Wastl</a> released in December a new puzzle each day until day 25. In general, the puzzles get more difficult over time.</p><p>Because I had so much fun last December, beginning of 2023, I decided to challenge myself: try to complete all the previous years and reach all the possible stars. After <strong>34,281</strong> lines of code written (tests not included), I wanted to write a post describing all the lessons I learned throughout this genuinely amazing experience 🚀.</p><p><strong>NOTE:</strong><em> I completed the Advents Of Code mainly in Go and a bit in Rust but I’ll keep this post as much as possible language-agnostic.</em></p><h3>Graphs, Graphs, And Graphs</h3><p>I never had to use fancy data structures to complete an Advent Of Code. Yet, we need to be familiar with the most common ones: arrays, linked lists, stacks, queues, heaps, trees, and… graphs.</p><p>Being comfortable with graphs is an absolute necessity: how to represent a graph and the most common algorithms. For me, the two algorithms I used the most, and by far, were:</p><ul><li><a href="https://en.wikipedia.org/wiki/Breadth-first_search">Breadth-First Search</a> (BFS): allows computing the shortest path in an unweighted graph</li><li><a href="https://en.wikipedia.org/wiki/Topological_sorting">Topological sorting</a>: allows to sort vertices</li></ul><p>Let’s delve a bit into the latter as it may be the one most people are the less comfortable with. Imagine the following scenario where we need to handle four different tasks. Yet, some tasks need to be completed before others:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/471/1*oEB-wori1oo3HVH4dr4RIg.png" /><figcaption>If there’s an edge from U to V, then U ≤ V</figcaption></figure><p>In this example, an arrow represents an <em>happens-before</em> relationship. For example, to complete D, we need to complete C first. But to complete C, we have to complete both A and B. Using topological sort, we could flatten the graph based on the edges representing the dependencies:</p><pre>A, B, C, D</pre><p>Why is this algorithm important? Let’s take <a href="https://adventofcode.com/2019/day/14">2019 day 14</a> as an example. We are given a list of chemical reactions:</p><pre>10 ORE =&gt; 10 A<br>1 ORE =&gt; 1 B<br>7 A, 1 B =&gt; 1 C<br>7 A, 1 C =&gt; 1 D<br>7 A, 1 D =&gt; 1 E<br>7 A, 1 E =&gt; 1 FUEL</pre><p>We need to calculate what’s the minimum number of ORE required to produce one FUEL. To solve this problem, my <a href="https://github.com/teivah/advent-of-code/blob/4c8ee7baaea91ad0590d62c9c233edc6e2236522/2019/day14-go/main.go#L24">solution</a> relied first on using topological sorting to model the transformation dependencies. Once modeled, I just had to start from a FUEL and then delve into the dependencies to get the final result.</p><p>All in all, completing the Advents Of Code allowed me to get way more comfortable working with graphs, and I discovered algorithms I wasn’t aware of (e.g., using <a href="https://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm">Floyd–Warshall</a> to calculate the length of shortest paths between all pairs of vertices which I used for <a href="https://adventofcode.com/2022/day/16">2022 day 16</a> <a href="https://github.com/teivah/advent-of-code/blob/a618d97d8c1bec769c4073ad863507910e638973/2022/day16-go/main.go#L65">here</a>). Doing an Advent Of Code is a great way to learn and practice algorithmics.</p><h3>Coding != Software Engineering</h3><p>As a software engineer, be it at Docker or in previous companies, most lines of code are written while keeping many factors in mind, such as maintainability, readability, expressiveness, etc. Different characteristics that do matter in the context of long-term projects with plenty of engineers working on the same codebase.</p><p>Yet, writing some code for the Advent Of Code or similar challenges is a complete different context. We don’t really care whether our solution is maintainable: we’re the only one to work on it, and once we get the two stars, we move to something else. We may face many challenges that aren’t necessarily the same as in our day-to-day job.</p><p>In the (great) <a href="https://www.goodreads.com/book/show/48816586-software-engineering-at-google"><em>Software Engineering at Google</em></a> book, there’s one quote that perfectly summarizes my point:</p><blockquote>“Software engineering is programming integrated over time”.</blockquote><p>The Advent Of Code made me realize again how much coding activity can sometimes be different from the job of a software engineer. As software engineers, we face the time dimension, which does impact our activity immensely. Sometimes for the best, sometimes for the worst.</p><h3>If a Result Is Random, It’s a Great Trail To Follow</h3><p>On some occasions, our code may produce a non-deterministic result; put another way, a result that varies from one execution to another. In this case, it’s actually not that bad. Facing such a scenario means tracking the parts in our code that lead to this non-deterministic result.</p><p>One case I faced pretty frequently was a non-deterministic result with my Go solution when using a map iteration. Indeed, in Go, iterating on a map is <em>unspecified</em>; it produces a (somewhat) random ordering. When I noticed such a behavior, it meant that the code inside the map iteration was necessarily wrong, and I needed to review that part carefully. And in many occasions, it was the issue preventing me from having a successful solution.</p><p>So if you face a non-deterministic result, try understanding what part of your code leads to such behavior. You may not have found the unique problem of your code, but it’s a trail you must follow.</p><h3>How to Rely on Algorithm Invariants</h3><p>Regardless of the language we use, we all have some ways to check <a href="https://en.wikipedia.org/wiki/Assertion_%28software_development%29">assertions</a>; said differently, verifying predicates in the code that should always be true. I found out that, sometimes, using assertions in my code was particularly useful.</p><p>For example, <a href="https://adventofcode.com/2016/day/11">2016 day 11</a>, I implemented a solution that handled different cases based on a variable value. At first, my code was written in a way that I wasn’t even handling one specific case. Indeed, this case was invalid, and I should never face it.</p><p>Yet, when I realized that my solution wasn’t correct, I added an assertion into my code to make sure that I was never facing this case, and surprise: I was. The problem wasn’t that this was a wrong invariant; it was because my code was, on some occasions, producing this incorrect value. It helped me find out what was the source of the problem.</p><p><strong>NOTE</strong>: <em>In Go, we can, for example, use </em>panic<em> to semantically express: “this is not an error per se; it’s an actual fault, and this case should never ever occur”.</em></p><p>So using assertions to model your algorithm invariants can sometimes be particularly useful, especially in the process of debugging why a solution doesn’t work.</p><h3>Beyond Big O</h3><p>The <a href="https://en.wikipedia.org/wiki/Big_O_notation">Big O notation</a> is a great way to model how an algorithm will scale. Yet, it’s far from being the only part to consider. For example, we may develop a solution with a quadratic complexity:<em> O(n²).</em> However, from which value of <em>n</em> will our solution becomes too slow to execute?</p><p>That made me realize that I was far from having a precise understanding of how many instructions can be run in a decent amount of time. For example, and the question is in Go, but the order or magnitude is probably similar for most programming languages: how long does it take to get <strong>100 million</strong> random entries from a map containing a thousand values (I purposely designed an experiment <em>not</em> to leverage CPU caches)?</p><ul><li>1 millisecond?</li><li>1 second?</li><li>10 seconds?</li><li>1 minute?</li><li>10 minutes?</li></ul><p>The answer is roughly one second. So, it takes one second to retrieve 100 million random entries from a map with a length of a thousand values.</p><p>Once you start understanding what’s feasible in a decent amount of time, you will also be able to confront your big O analysis against your possible solution. Sure, in <a href="https://adventofcode.com/2017/day/15#part1">2017 day 15</a> we needed to repeat an operation 40 million times, but <a href="https://github.com/teivah/advent-of-code/blob/16293c8493fd9173d156c4c43f1c60ae9be32567/2017/day15-go/main.go#L15">my solution</a> runs in less than 20 milliseconds.</p><p>The more you practice, the more you’ll be able to have some <em>sense</em> of how long your solution should run, and this is invaluable knowledge.</p><p><strong>NOTE:</strong><em> A great addition to this very point is the page created by Julia Evans and Kamal Marhubi: </em><a href="https://computers-are-fast.github.io/"><em>Do you know how much your computer can do in a second?</em></a><em> It gives a list of examples showing what a program can tackle within a second.</em></p><h3>Mutability Can Be a Source Of Mistakes</h3><p>During <a href="https://adventofcode.com/2018/day/22">2018 day 22</a>, we were given a way to <em>generate</em> a map (the map itself isn’t an input), and we needed to find the shortest path from one point (<em>M</em>) to another (<em>T</em>). One challenge was also the fact that the map wasn’t bounded, and perhaps, the shortest path was going through rows below the actual target (the <em>X</em>s represent the shortest path):</p><pre><strong>M</strong>=.|=.|.|=.|=|=.<br>XXXXX|||..|.=...<br>.==|X...||=..|==<br>=.|.X..|.==.|==.<br>=|..X=...=.|==..<br>=||.X.=||=|=..|=<br>|.=.X==|||..=..|<br>|..=X||=.|==|===<br>.=..XX=..=|.|||.<br>.====X=|||=|=.|=<br>.===|X|===<strong>T</strong>===||<br>=|||.XX|==X.|=.|<br>=.=|=.XXXXX||==| &lt;-- Passing through this row<br>||=|=...|==.=|==<br>|=.=||===.|||===<br>||.|==.|.|.||=|| </pre><p>In my solution, I updated two parameter variables by adding an extra length:</p><pre>func toCave(depth, targetCol, targetRow int) *Cave {<br>   const (<br>      extraRow = 100<br>      extraCol = 100<br>   )<br><br>   targetCol += extraCol // Mutate parameter variable<br>   targetRow += extraRow // Mutate parameter variable<br>   // ...<br>} </pre><p>This code is 100% valid: variables in Go are mutable. Yet, it caused me a lot of pain to understand why my solution wasn’t passing. Indeed, throughout this function, I was using targetCol and targetRow in two different ways:</p><ul><li>To represent the max size of the 2D array</li><li>But also to indicate the coordinates of the target</li></ul><p>In both cases, that was stupid. For the former, it was a semantic issue; I was using a variable called targetXXX for something that wasn’t really a target. And for the latter, that was a pure bug because the target I was searching for (<em>T</em>) wasn’t anymore the actual target because of this extra delta I was adding.</p><p>In my case, I should have created two new variables:</p><pre>func toCave(depth, targetCol, targetRow int) *Cave {<br>   const (<br>      deltaRow = 100<br>      deltaCol = 100<br>   )<br><br>   totalCol := targetCol+ deltaCol // New variable<br>   totalRow := targetRow + deltaRow // New variable<br>   // ...<br>}</pre><p>So bear in mind that mutability, even if allowed, can sometimes be a source of mistakes. At the very least, keep a consistent semantic meaning for a variable throughout your function.</p><h3>What if a Solution Solves the Example but Not the Puzzle Input</h3><p>I’m pretty sure that it happens to all of us. We implement a solution, we run it against the small example given during the day description, and the test passes. Then, we run our solution against our puzzle input and click on submit confidently, but we get this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DbNRgWZxh8QzAyhIns17Tg.png" /><figcaption>Sadness.</figcaption></figure><p>The first thing I do in this case (I mean apart from suspecting a bug in the Advent Of Code solutions which is <em>never</em> the case) is to run a successful test using the code coverage feature of my IDE:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_JvzA7eRG0ixehvgdFDlnQ.png" /><figcaption>On the left-hand side, the red part represents the code path not covered.</figcaption></figure><p>Why do this? If your solution works for one example and not another, there is a significant probability that the issue lies in the code not covered. It might not be 100% true (for example, a bug might be present only if a line of code is executed twice), but it saved me on many occasions.</p><h3>When You’re Stuck 1/3: Try Visualizing Your Data</h3><p>If you’re stuck on a problem, one of the possible approaches is trying to visualize your data.</p><p>It happened to me on <a href="https://adventofcode.com/2018/day/23">2018 day 23</a>. In a nutshell, we’re given a list of robots having a position and a range, and we need to calculate the coordinate in the range of the largest number of robots. One <em>small</em> problem, the coordinates, and ranges are gigantic:</p><pre>pos=&lt;-34870395,34498817,-2843154&gt;, r=96244937<br>pos=&lt;-52741579,9875242,37136273&gt;, r=89509114<br>pos=&lt;23303891,41664349,2510522&gt;, r=63042453<br>pos=&lt;10573027,54782809,49932958&gt;, r=97928881<br>pos=&lt;30268215,-1711562,83940876&gt;, r=91888282<br>...</pre><p>Because of the scale, a brute-force solution should complete in a few million years. For some time, I was completely stuck. Then, I tried visualizing the input data. So dividing all the coordinates by five million and then checking where the clusters were. By doing that, I was able to notice that the most interesting coordinates were inside one little square:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/391/1*8VzL0PUPln0vGdl9GspXFw.png" /><figcaption>A 1 represents an interesting coordinate.</figcaption></figure><p>Thanks to that, I came up with an algorithm that:</p><ul><li>Divides all the coordinates by one million, selects the most interesting area, and delves into it.</li><li>Then it divides the coordinates by 100 thousand, selects the most interesting area, and delves into it.</li><li>Etc.</li></ul><p>Finally, the range I’m iterating over is small enough to make my code run in a reasonable time.</p><p>So, sometimes when you’re stuck, try visualizing your data. Humans work well when they have a mental picture of the problem.</p><h3>When You’re Stuck 2/3: Try Another Approach</h3><p>It looks like a dumb advice: if you’re stuck on an approach, you should find another one. Or perhaps it’s because I’m dumb enough, but I really struggled sometimes to apply this advice. On some occasions, it took me hours to realize that my solution was a dead end. I can’t emphasize enough how important it is sometimes to take a step back on your solution and try to understand why it won’t work.</p><p>For example, <a href="https://adventofcode.com/2015/day/19#part2">2015 day 19 part 2</a> (a problem involving some string transformations), I spent way too much time trying to solve the problem from the start to the target, whereas it took me only a few minutes to solve the other way around, from the target to the start.</p><p>So you need to be able sometimes to realize yourself that a solution is a dead end. For that, the following point is sometimes mandatory.</p><h3>When You’re Stuck 3/3: Go Do Something Else, or Go Get Some Sleep!</h3><p>It might sound like a joke, but it’s not. Sometimes, when you’re stuck on an issue, the best option for us is to stop. Go get a shower, watch a movie, read a book, get some sleep, etc. In other words, give your brain some rest.</p><p>I hadn’t counted the number of times when I was stuck on a problem, and I started doing something else, I came up with ideas. It wasn’t necessarily the actual solution, but some food for thought, some test cases to check, etc. Even if sometimes it’s far from being easy, force yourself to do something else to improve your chances of success.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pxyGn-9NvkRf7OYFGVHX6g.png" /></figure><p><strong>NOTE:</strong><em> I struggled with this piece of advice for myself. On some occasions, I worked until being mentally exhausted. Sometimes it’s easy to give advice that you don’t follow yourself!</em></p><h3>The Advent Of Code Made Me Love Algorithms and Data Structures Again</h3><p>I don’t know about you, but personally, the moment I have to use data structures the most (I mean outside <em>just</em> arrays and maps) is when I prepare coding interviews. And because of this context, I tend to associate those topics with something constraining: I don’t do it because I enjoy it; I do it because I have to.</p><p>Thanks to the Advent Of Code, it made me love working again on algorithmics. I started reading <a href="https://www.manning.com/books/advanced-algorithms-and-data-structures">Advanced Algorithms and Data Structures</a> by Marcello La Rocca because I want to extend my knowledge beyond the basic data structures we have to know during coding interviews, such as K-d trees, clustering, d-way heaps, gradient descent, etc. There are so many things to learn in this domain. It’s truly fascinating.</p><p><em>If you enjoyed this post, you may be interested in my newsletter:</em></p><figure><a href="https://thecoder.cafe/?rd=medium.com"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oWmtn60p9nE84-ixm_ehdw.png" /></a></figure><h3>Conclusion</h3><p>A massive thank you to <a href="http://was.tl/">Eric Wastl</a> and all the people working on the Advent Of Code ❤️. I can’t praise enough how great my experience was, and if you’re not familiar with the Advent Of Code or a bit reluctant, you should definitely try it!</p><p>In the meantime, here’s my GitHub repository:</p><p><a href="https://github.com/teivah/advent-of-code">GitHub - teivah/advent-of-code: 🎄 My solutions to the Advent of Code, from 2015 to 2022 (400 ⭐️).</a></p><h3>Bonus</h3><ul><li>Is that normal to struggle that much to implement a doubly linked list in Rust? Because such <a href="https://rust-unofficial.github.io/too-many-lists/">website</a> exists, I feel like the answer is yes.</li><li>3D is hard! At least for me. I have never been good at visualizing data in a 3D space. I struggled immensely with days such as <a href="https://adventofcode.com/2021/day/21">2021 day 21</a> or <a href="https://adventofcode.com/2022/day/22">2022 day 22 part 2</a> (no, not a 3D cube! 😱).</li><li>The people competing for the <a href="https://adventofcode.com/2022/leaderboard">global leaderboard</a> are really great. Among them, <a href="https://github.com/betaveros">betaveros</a> is genuinely remarkable. This guy is almost consistently ranked in the top 10 every day. Having people like him forces you to stay humble.</li><li>If you want to start an Advent Of Code, I would recommend you either to start building your own library or reusing an existing one. For example, the activity of parsing the puzzle inputs should be as fast as possible. Even if you don’t compete for a leaderboard, what matters is to focus on the actual problem. Hence, relying on a library for common utilities is important. If you use Go, you can take a look at the one I built <a href="https://github.com/teivah/advent-of-code/blob/main/lib.go#L12">here</a>. I also made a small <a href="https://github.com/teivah/advent-of-code/blob/main/new.sh">script</a> to generate a new project and automatically import the puzzle input.</li></ul><figure><a href="http://teivah.io"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0HNtD9z-GokpUrioBHkxWQ.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b5bf35a6d115" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Profiling and Execution Tracing in Go]]></title>
            <link>https://teivah.medium.com/profiling-and-execution-tracing-in-go-a5e646970f5b?source=rss-1c96b0f1c413------2</link>
            <guid isPermaLink="false">https://medium.com/p/a5e646970f5b</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[Teiva Harsanyi]]></dc:creator>
            <pubDate>Fri, 23 Dec 2022 17:01:29 GMT</pubDate>
            <atom:updated>2023-09-27T08:25:30.091Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bLoSnDEA_rlqTZjBE88fQg.png" /></figure><p>Moved to <a href="https://100go.co/98-profiling-execution-tracing/">100go.co</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a5e646970f5b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Slice length vs. capacity in Go]]></title>
            <link>https://teivah.medium.com/slice-length-vs-capacity-in-go-af71a754b7d8?source=rss-1c96b0f1c413------2</link>
            <guid isPermaLink="false">https://medium.com/p/af71a754b7d8</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[go]]></category>
            <dc:creator><![CDATA[Teiva Harsanyi]]></dc:creator>
            <pubDate>Wed, 09 Nov 2022 14:01:12 GMT</pubDate>
            <atom:updated>2023-09-27T08:26:02.648Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vg8Zx5ZtONVUpM-9RaJ6Tg.png" /></figure><p>Moved to <a href="https://100go.co/20-slice/">100go.co</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=af71a754b7d8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Maps and Memory Leaks in Go]]></title>
            <link>https://teivah.medium.com/maps-and-memory-leaks-in-go-a85ebe6e7e69?source=rss-1c96b0f1c413------2</link>
            <guid isPermaLink="false">https://medium.com/p/a85ebe6e7e69</guid>
            <category><![CDATA[go]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Teiva Harsanyi]]></dc:creator>
            <pubDate>Wed, 28 Sep 2022 07:55:58 GMT</pubDate>
            <atom:updated>2023-09-27T08:26:52.480Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FhBXHcytS2UTSzWmWM2FhA.png" /></figure><p>Moved to <a href="https://100go.co/28-maps-memory-leaks/">100go.co</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a85ebe6e7e69" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Concurrency isn’t Always Faster in Go]]></title>
            <link>https://teivah.medium.com/concurrency-isnt-always-faster-in-go-de325168907c?source=rss-1c96b0f1c413------2</link>
            <guid isPermaLink="false">https://medium.com/p/de325168907c</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Teiva Harsanyi]]></dc:creator>
            <pubDate>Wed, 14 Sep 2022 08:02:46 GMT</pubDate>
            <atom:updated>2023-09-27T16:04:44.035Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1_rkOsFqB1d6ciV8Ubn63Q.png" /></figure><p>Moved to <a href="https://100go.co/56-concurrency-faster/">100go.co</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de325168907c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Write Accurate Benchmarks in Go]]></title>
            <link>https://teivah.medium.com/how-to-write-accurate-benchmarks-in-go-4266d7dd1a95?source=rss-1c96b0f1c413------2</link>
            <guid isPermaLink="false">https://medium.com/p/4266d7dd1a95</guid>
            <category><![CDATA[go]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Teiva Harsanyi]]></dc:creator>
            <pubDate>Wed, 31 Aug 2022 07:07:09 GMT</pubDate>
            <atom:updated>2023-09-27T08:27:25.936Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WHnWeQlBBPMz6M9VOA7Gmw.png" /></figure><p>Moved to <a href="https://100go.co/89-benchmarks/">100go.co</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4266d7dd1a95" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ 100 Go Mistakes: Released!]]></title>
            <link>https://teivah.medium.com/100-go-mistakes-released-d48bcc391167?source=rss-1c96b0f1c413------2</link>
            <guid isPermaLink="false">https://medium.com/p/d48bcc391167</guid>
            <category><![CDATA[go]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Teiva Harsanyi]]></dc:creator>
            <pubDate>Thu, 25 Aug 2022 10:37:50 GMT</pubDate>
            <atom:updated>2025-01-20T08:57:20.128Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0HxQ62iIoX_khvxhAiz9OQ.png" /></figure><p>After almost three years of work, I wanted to announce that my book, <em>100 Go Mistakes and How to Avoid Them</em>, has finally been released 🎉.</p><blockquote><em>100 Go Mistakes and How to Avoid Them</em> shows you how to replace common programming problems in Go with idiomatic, expressive code. In it, you’ll explore dozens of interesting examples and case studies as you learn to spot mistakes that might appear in your own applications.</blockquote><h3>How it Started</h3><p>In 2019, I started my second professional experience with Go as the primary language. While working in this new context, I noticed some common patterns regarding Go coding mistakes. I started to think that perhaps writing about these frequent mistakes could help some developers.</p><p>So, I wrote a blog post called “<a href="https://itnext.io/the-top-10-most-common-mistakes-ive-seen-in-go-projects-4b79d4f6cd65">The Top 10 Most Common Mistakes I’ve Seen in Go Projects</a>.” The post was very popular: it had more than 100,000 reads and was selected by the Golang Weekly newsletter as one of the <a href="https://golangweekly.com/issues/293">top articles of 2019</a>. Beyond that, I was pleased with the positive feedback I got from the Go community.</p><p>From that moment, I realized that communicating about common mistakes was a powerful tool. Accompanied by concrete examples, it can help people learn new skills efficiently and facilitate remembering the context of a mistake and how to avoid it.</p><p>I spent about a year compiling mistakes from various sources such as other professional projects, open source repositories, books, blogs, studies, and discussions with the Go community. To be transparent, I was also a decent source of inspiration regarding mistakes.</p><p>At the end of 2020, I reached 100 Go mistakes, which seemed to me like the right moment to propose my idea to a publisher: Manning. Then, it took me almost 2 years and countless iterations to frame each of the 100 mistakes alongside meaningful examples and multiple solutions where context is key.</p><p>I hope this book will help you avoid making these common mistakes and help you enhance your proficiency in the Go language.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T9QGdj2BkN4-ieVBgeRjAg.jpeg" /><figcaption>The land of Go mistakes</figcaption></figure><h3>Where to Buy the Book</h3><p>For the time being, the physical book is available on Manning’s website: <a href="https://www.manning.com/books/100-go-mistakes-and-how-to-avoid-them">https://www.manning.com/books/100-go-mistakes-and-how-to-avoid-them</a> (-35% with the code <strong>au35har</strong>). On Amazon and other platforms, it’ll take a little bit more time to prepare the stocks, but the book can already be preordered.</p><p>In the meantime, I’ve prepared a GitHub repo containing the source code and a summary of each mistake described in the book. I also have in mind this it could become a collaborative place where people could contribute and propose common mistakes; let’s see if that works out.</p><p><a href="https://github.com/teivah/100-go-mistakes">GitHub - teivah/100-go-mistakes: Source code and community space of 📖 100 Go Mistakes</a></p><h3>What’s Next</h3><p>In the following weeks, I will be active again on my blog, starting with posts taken from the book. As each mistake is almost always independent, it will fit quite well in a blog post format.</p><p>Thanks to all the people involved, and thanks to the Go community!</p><p><em>If you enjoyed this post, you may be interested in my newsletter:</em></p><figure><a href="https://thecoder.cafe/?rd=medium.com"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oWmtn60p9nE84-ixm_ehdw.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d48bcc391167" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When to Use Generics in Go?]]></title>
            <link>https://teivah.medium.com/when-to-use-generics-in-go-36d49c1aeda?source=rss-1c96b0f1c413------2</link>
            <guid isPermaLink="false">https://medium.com/p/36d49c1aeda</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[generics]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Teiva Harsanyi]]></dc:creator>
            <pubDate>Wed, 15 Dec 2021 21:50:07 GMT</pubDate>
            <atom:updated>2023-09-27T08:27:57.807Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/619/1*hXQ1e00vRPQWk_j6acPiUA.png" /></figure><p>Moved to <a href="https://100go.co/9-generics/">100go.co</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=36d49c1aeda" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>