<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Programmings on May Meow</title>
    <link>https://maymeow.blog/programming/</link>
    <description>Recent content in Programmings on May Meow</description>
    <generator>Hugo</generator>
    <language>en</language>
    <copyright>Copyright © 2020, May Meow.</copyright>
    <lastBuildDate>Sat, 16 May 2026 23:37:46 +0200</lastBuildDate>
    <atom:link href="https://maymeow.blog/programming/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>🎄 Advent of Code &#39;25 Day 5: Cafeteria</title>
      <link>https://maymeow.blog/programming/aoc25-day5-cafeteria/</link>
      <pubDate>Fri, 05 Dec 2025 09:55:54 +0200</pubDate>
      <guid>https://maymeow.blog/programming/aoc25-day5-cafeteria/</guid>
      <description>&lt;p&gt;Day 5 felt like running a little data pipeline: we ingest ranges, normalize them, and answer two slightly different queries.&lt;/p&gt;&#xA;&lt;h2 id=&#34;part-1--checking-the-available-ids&#34;&gt;Part 1 – Checking the available IDs&lt;/h2&gt;&#xA;&lt;p&gt;The database lists “fresh” ID ranges followed by a blank line and then the list of available items we need to classify. My approach:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Parse the ranges and IDs.&lt;/li&gt;&#xA;&lt;li&gt;Sort and merge overlapping or adjacent ranges so we end up with disjoint intervals.&lt;/li&gt;&#xA;&lt;li&gt;For each ID, run a binary search to see whether it lands inside any merged interval.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; Merging ranges costs &lt;code&gt;O(R log R)&lt;/code&gt; where &lt;code&gt;R&lt;/code&gt; is the number of range lines. Each ID lookup is &lt;code&gt;O(log R)&lt;/code&gt;, so the total runtime is &lt;code&gt;O(R log R + I log R)&lt;/code&gt;; memory stays &lt;code&gt;O(R)&lt;/code&gt; for the merged intervals.&lt;/p&gt;</description>
    </item>
    <item>
      <title>🎄 Advent of Code &#39;25 Day 4: Printing Department</title>
      <link>https://maymeow.blog/programming/aoc25-day4-printing-department/</link>
      <pubDate>Thu, 04 Dec 2025 08:23:54 +0200</pubDate>
      <guid>https://maymeow.blog/programming/aoc25-day4-printing-department/</guid>
      <description>&lt;p&gt;Forklifts, paper rolls, and lots of adjacency checks: Day 4 turned into a neat graph-like puzzle. Here’s how I solved both parts and what their complexity looks like.&lt;/p&gt;&#xA;&lt;h2 id=&#34;part-1--finding-accessible-rolls&#34;&gt;Part 1 – Finding accessible rolls&lt;/h2&gt;&#xA;&lt;p&gt;Each roll of paper is represented by &lt;code&gt;@&lt;/code&gt; on a grid. A roll is accessible if fewer than four of the eight neighboring cells also contain rolls. The solver:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Parses the grid from &lt;code&gt;input.txt&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Walks every cell; when it finds an &lt;code&gt;@&lt;/code&gt;, it counts the occupied neighbors using the eight-direction offsets.&lt;/li&gt;&#xA;&lt;li&gt;Increments the answer whenever the neighbor count is &lt;code&gt;&amp;lt; 4&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; Let the grid be &lt;code&gt;H x W&lt;/code&gt;. We inspect each cell once and examine up to eight neighbors, so runtime is &lt;code&gt;O(H * W)&lt;/code&gt; with &lt;code&gt;O(1)&lt;/code&gt; auxiliary memory.&lt;/p&gt;</description>
    </item>
    <item>
      <title>🎄 Advent of Code &#39;25 Day 3: Lobby</title>
      <link>https://maymeow.blog/programming/aoc25-day3-lobby/</link>
      <pubDate>Wed, 03 Dec 2025 11:23:54 +0200</pubDate>
      <guid>https://maymeow.blog/programming/aoc25-day3-lobby/</guid>
      <description>&lt;p&gt;I spent Day 3 hanging out in the lobby with a pile of battery banks and a stubborn escalator. Here is how I cracked both puzzles using a pair of lean JavaScript scripts (&lt;code&gt;part1.js&lt;/code&gt; and &lt;code&gt;part2.js&lt;/code&gt;).&lt;/p&gt;&#xA;&lt;h2 id=&#34;part-1--two-batteries-one-number&#34;&gt;Part 1 – Two batteries, one number&lt;/h2&gt;&#xA;&lt;p&gt;Each bank is a string of digits. I needed the largest possible two-digit value that preserves order. Rather than evaluate every pair, I sweep the string once while tracking the best &amp;ldquo;first&amp;rdquo; digit seen so far. Every new digit forms a candidate pair with that best digit; if the candidate beats the running maximum, I store it, and if the new digit is even better as a first digit, I promote it. This greedy pass extracts the answer for a bank in linear time.&lt;/p&gt;</description>
    </item>
    <item>
      <title>🎄 Advent of Code &#39;25 Day 2: Gift Shop</title>
      <link>https://maymeow.blog/programming/aoc25-day2-gift-shop/</link>
      <pubDate>Tue, 02 Dec 2025 09:07:54 +0200</pubDate>
      <guid>https://maymeow.blog/programming/aoc25-day2-gift-shop/</guid>
      <description>&lt;p&gt;Day 2 was all about spotting playful ID patterns inside huge numerical ranges. Here’s how both parts came together.&lt;/p&gt;&#xA;&lt;h2 id=&#34;input-parsing-shared-by-both-parts&#34;&gt;Input parsing shared by both parts&lt;/h2&gt;&#xA;&lt;p&gt;The puzzle input is one comma-separated line of inclusive ranges (&lt;code&gt;start-end&lt;/code&gt;). I parse everything as &lt;code&gt;BigInt&lt;/code&gt; so that the gigantic IDs stay precise. After that, each part does its own math on top of the same parsed data.&lt;/p&gt;&#xA;&lt;h2 id=&#34;part-1--double-half-ids&#34;&gt;Part 1 – Double-half IDs&lt;/h2&gt;&#xA;&lt;p&gt;&lt;strong&gt;Condition.&lt;/strong&gt; An ID is invalid if it is exactly two copies of some digit string (e.g., &lt;code&gt;64 64&lt;/code&gt;). If the repeated block has length &lt;code&gt;h&lt;/code&gt;, then the ID equals &lt;code&gt;pattern * 10^h + pattern&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>🎄 Advent of Code &#39;25 Day 1: Secret Entrance</title>
      <link>https://maymeow.blog/programming/aoc25-day1-secret-entrance/</link>
      <pubDate>Mon, 01 Dec 2025 10:02:54 +0200</pubDate>
      <guid>https://maymeow.blog/programming/aoc25-day1-secret-entrance/</guid>
      <description>&lt;p&gt;For Day 1 I had to open a safe with a dial numbered 0–99. Here’s how both halves of the puzzle fell.&lt;/p&gt;&#xA;&lt;h2 id=&#34;part-1--counting-end-of-rotation-zeros&#34;&gt;Part 1 – Counting end-of-rotation zeros&lt;/h2&gt;&#xA;&lt;p&gt;The dial starts at 50 and each instruction looks like &lt;code&gt;L68&lt;/code&gt; or &lt;code&gt;R48&lt;/code&gt;. I only needed to know how many times the dial ended on 0 &lt;strong&gt;after finishing&lt;/strong&gt; each rotation.&lt;/p&gt;&#xA;&lt;p&gt;Implementation notes:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Parse every instruction once.&lt;/li&gt;&#xA;&lt;li&gt;Track the current dial position; rotate by converting &lt;code&gt;L&lt;/code&gt; to negative steps and &lt;code&gt;R&lt;/code&gt; to positive steps.&lt;/li&gt;&#xA;&lt;li&gt;Apply the delta with &lt;code&gt;(position + delta) mod 100&lt;/code&gt; keeping values non-negative.&lt;/li&gt;&#xA;&lt;li&gt;Increment the answer whenever the resulting position equals 0.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;This runs in O(n) with n rotations and needs only a handful of integers.&lt;/p&gt;</description>
    </item>
    <item>
      <title>🎄 Advent of Code Day 10</title>
      <link>https://maymeow.blog/programming/advent-of-code-day-10/</link>
      <pubDate>Sun, 10 Dec 2023 17:24:43 +0100</pubDate>
      <guid>https://maymeow.blog/programming/advent-of-code-day-10/</guid>
      <description>&lt;p&gt;Today you are looking at a strange metal country with lots of pipes. How did I get there? Oh, with the glider - I had to read it again while writing this post. After quickly sketching the positions of all the pipes, you get this&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;..F7.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;2&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;.FJ|.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;3&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;SJ.L7&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;4&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;|F--J&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;5&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;LJ...&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And also have a legend of what each of the symbols mean. For easier understanding, I made a much simpler map that contains only empty ground and starting position.&lt;/p&gt;</description>
    </item>
    <item>
      <title>🎄 Advent of Code Day 09</title>
      <link>https://maymeow.blog/programming/advent-of-code-day-09/</link>
      <pubDate>Sat, 09 Dec 2023 22:02:04 +0100</pubDate>
      <guid>https://maymeow.blog/programming/advent-of-code-day-09/</guid>
      <description>&lt;p&gt;Today&amp;rsquo;s problem contains a prediction of the next values for the Oasis and Sand instability sensors. You are looking at the report that contains the history. This report looks like this and you need to predict next values.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;0 3 6 9 12 15&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;2&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;1 3 6 10 15 21&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;3&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;10 13 16 21 30 45&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To do this, you must create a new sequence by doing the difference at each step of your history. If the new sequence is not all zeros, you have to repeat the process with the sequence you just created. At the end you will have a bunch of sequences that look like this.&lt;/p&gt;</description>
    </item>
    <item>
      <title>🎄 Advent of Code Day 08</title>
      <link>https://maymeow.blog/programming/advent-of-code-day-08/</link>
      <pubDate>Fri, 08 Dec 2023 19:01:22 +0100</pubDate>
      <guid>https://maymeow.blog/programming/advent-of-code-day-08/</guid>
      <description>&lt;p&gt;Today&amp;rsquo;s quest is called Haunted Wasteland. You are riding a camel across a desert island. You find a map in one of the camel&amp;rsquo;s bags. The map contains instructions on how to navigate through the desert and a bunch of knots. It looks like this&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;RL&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;2&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;3&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;AAA = (BBB, CCC)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;4&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;BBB = (DDD, EEE)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;5&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;CCC = (ZZZ, GGG)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;6&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;DDD = (DDD, DDD)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;7&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;EEE = (EEE, EEE)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;8&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;GGG = (GGG, GGG)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;9&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;ZZZ = (ZZZ, ZZZ)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You start at node &lt;code&gt;AAA&lt;/code&gt; and need to get to node &lt;code&gt;ZZZZ&lt;/code&gt;.  And you need to know how many steps it takes to get to node &lt;code&gt;ZZZ&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>📦 Uploading Files With Cake Php and Fileupload Plugin</title>
      <link>https://maymeow.blog/programming/uploading-files-with-cake-php-and-fileupload-plugin/</link>
      <pubDate>Sun, 24 Oct 2021 09:09:36 +0200</pubDate>
      <guid>https://maymeow.blog/programming/uploading-files-with-cake-php-and-fileupload-plugin/</guid>
      <description>&lt;p&gt;I just release new version of my &lt;a href=&#34;https://github.com/MayMeow/cakephp-fileupload&#34;&gt;FileUpload&lt;/a&gt; plugin for &lt;a href=&#34;https://cakephp.org/&#34;&gt;CakePHP&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;It will make uploading and downloading files really easi. Want to see? Continue reading.&lt;/p&gt;&#xA;&lt;h2 id=&#34;prerequisites&#34;&gt;Prerequisites&lt;/h2&gt;&#xA;&lt;p&gt;If you have existing application you can skip right to &lt;strong&gt;Create fileupload app&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;CakePHP 4&lt;/li&gt;&#xA;&lt;li&gt;Https server&lt;/li&gt;&#xA;&lt;li&gt;PHP 7.x or 8&lt;/li&gt;&#xA;&lt;li&gt;php extensions mgstring, intl, SimpleXML, PDO&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;For more informations check &lt;a href=&#34;https://book.cakephp.org/4/en/installation.html&#34;&gt;CakePHP Installation&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;OR&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Docker&lt;/li&gt;&#xA;&lt;li&gt;Docker-compose&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Right, only those two. I will show you ho to do it in this tutorial.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
