{
    "componentChunkName": "component---src-templates-post-js",
    "path": "/blog/aoc22",
    "result": {"data":{"markdownRemark":{"html":"<p><em>Using <a href=\"https://adventofcode.com/2022\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Advent of Code 2022</a> as an opportunity to familiarize myself with a new programming language.</em></p>\n<hr>\n<p>Today was the beginning of a new adventure - learning Python. Armed with a background in Java, JavaScript, and TypeScript, I was eager to see how this new language would shape my coding journey.</p>\n<h2>Python's Simplicity</h2>\n<p>Having spent time with Java, JavaScript, and TypeScript, Python's clean syntax felt refreshingly straightforward.</p>\n<h3>Indentation: A New Way of Structuring Code</h3>\n<p>One of the initial differences I noticed was Python's use of indentation to denote code blocks. Unlike the familiar curly braces and semicolons, Python relies on consistent spacing to define the structure of the code. It felt strange at first, but I quickly came to appreciate the visual clarity it brought to my programs.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">python\n# Java Code\nfor (int i = 0; i &lt; arr.length; i++) {\n  System.out.println(\"Hello\");\n}\n\n# Python Code\nfor i in range(len(arr)):\n  print(\"Hello\")</code></pre></div>\n<h3>Swapping Values: A Pleasant Surprise</h3>\n<p>One of the first things that caught my attention was Python's elegant way of swapping values between variables. In Java, I was accustomed to using a temporary variable for such operations, but Python offered a more concise approach.</p>\n<div class=\"gatsby-highlight\" data-language=\"python\"><pre class=\"language-python\"><code class=\"language-python\"><span class=\"token operator\">//</span> Java\n<span class=\"token builtin\">int</span> temp <span class=\"token operator\">=</span> a<span class=\"token punctuation\">;</span>\na <span class=\"token operator\">=</span> b<span class=\"token punctuation\">;</span>\nb <span class=\"token operator\">=</span> temp<span class=\"token punctuation\">;</span>\n\n<span class=\"token comment\"># Python</span>\na<span class=\"token punctuation\">,</span> b <span class=\"token operator\">=</span> b<span class=\"token punctuation\">,</span> a</code></pre></div>\n<h2>Embracing the Pythonic Way</h2>\n<p>Python's 'Pythonic' way of doing things quickly became evident. It encouraged a more streamlined and intuitive approach to problem-solving. For instance, the built-in functions and libraries were extensive and saved me from reinventing the wheel.</p>\n<div class=\"gatsby-highlight\" data-language=\"python\"><pre class=\"language-python\"><code class=\"language-python\"><span class=\"token comment\"># Finding the maximum value in a list</span>\nmax_value <span class=\"token operator\">=</span> <span class=\"token builtin\">max</span><span class=\"token punctuation\">(</span>my_list<span class=\"token punctuation\">)</span> <span class=\"token comment\"># Python</span>\n\n<span class=\"token operator\">//</span> JavaScript\nconst max_value <span class=\"token operator\">=</span> Math<span class=\"token punctuation\">.</span><span class=\"token builtin\">max</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">.</span><span class=\"token punctuation\">.</span><span class=\"token punctuation\">.</span>myArray<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span> <span class=\"token operator\">//</span> JavaScript</code></pre></div>\n<h2>Conclusion</h2>\n<p>Day 0 of my Python journey was both exciting and enlightening. The transition from my familiar languages was smoother than expected, and Python's elegance and simplicity left me eager for more. Using Advent of Code 2022 as my playground, I could feel my confidence in Python growing with each challenge.</p>\n<p>As I closed my laptop, I couldn't help but feel a sense of accomplishment. I was ready for the days ahead, eager to explore more of Python's capabilities. With a newfound perspective and a sense of excitement, I looked forward to Day 1, knowing it held new puzzles and new opportunities for me to sharpen my Python skills.</p>\n<h2>Resources</h2>\n<ul>\n<li><a href=\"https://docs.python.org/3/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Python Documentation</a></li>\n<li><a href=\"https://adventofcode.com/2022\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Advent of Code 2022</a></li>\n</ul>\n<h2><a href=\"/blog/aoc22/day1\">Read about Day 1 -></a></h2>","frontmatter":{"title":"Day 0 of learning Python","description":"Using Advent of Code 2022 as an opportunity to familiarize myself with a new programming language.","date":"2022-12-01T00:00:00.000Z","slug":"/blog/aoc22","tags":["AdventOfCode2022","Python"]}}},"pageContext":{}},
    "staticQueryHashes": ["1994492073","2009693873","3081057667","3825832676"]}