Why Can't You Loop Over Ranges of Characters in Swift

This is a follow up from my previous post: The power and expressiveness of Swift ranges. For a Character Range: contain works fine let numericalRange = 1...10 numericalRange.contains(8) // true let a: Character = "a" let z: Character = "z" let alphabeticalRange = a...z alphabeticalRange.contains("k") // true for-loop and count don’t work print(numericalRange.count) // 10 print(alphabeticalRange.count) // ❌ Referencing property 'count' on 'ClosedRange' requires that 'Character' conform to 'Strideable' for num in numericalRange { print(num) // 1 2 3 4 5 6 7 8 9 10 } for char in alphabeticalRange { // ❌ Referencing instance method 'next()' on 'ClosedRange' requires that 'Character' conform to 'Strideable' print(char) } What both of those errors mean is that Swift can’t figure out what the next character is for a given character....

November 30, 2024 · 6 min

How Quantifying Impact Helps Your Career Growth

Learning from my product peers, TIL if you’re making an impactful change, it’s not just about the change itself—it’s about how you communicate its success. A compelling story can amplify your impact, but every great story needs a foundation of data to back it up. Logs, metrics, and dashboards are essential tools that help you visualize, quantify the problem and measure the impact of your solution from the perspectives of:...

November 15, 2024 · 3 min

How Do Binaries work together? What breaks ABI?

For two (dynamic) libraries to work together they need: API compatibility ABI compatibility If you have correct function, parameter names, and are able to access it (it’s not private) then you’re good. The compiler validates if classA is using the correct Programming Interface from classB 👈 API (Application Programming Interface) Example of API usage struct House { var address = Address(streetAddress: "1100 Happy St.") } struct Person { var address = Address("1100 Sad St....

October 20, 2024 · 10 min

Some vs Any

What problem do some and any solve? var x: Equatable = 10 // Error: Use of protocol 'Equatable' as a type must be written 'any Equatable' var y: Equatable = "10" // Same error You’s think the compiler should let the above compile, it rightfully doesn’t. The compiler can’t know if the associated type of x, matches with the associated type of y. So it just forbids it. Compiler just doesn’t want to be in situation where you’d try something like:...

July 17, 2024 · 4 min

Hugo Post Formatting Basics

Markdown Your posts can be formatted using markdown syntax. It’s critical to know how it works. It’s super simple. Frontmatter You can add tags: [swift, json, network call] and it will then add the tags to your post. Add showToc: true and will show a table of contents for your post. Hugo automatically takes the first 70 words of your content as its summary and stores it into the ....

May 3, 2024 · 4 min

Hugo High Level

This is the 2nd post of “Everything I learned from blogging with Hugo” series Why Hugo? Hugo is a Static Site Generator. Key is the word “static”. It means: A static website is made up of one or more HTML webpages that load the same way every time. Static websites contrast with dynamic websites, which load differently based on any number of changing data inputs, such as the user’s location, the time of day, or user actions....

April 30, 2024 · 7 min
First to the key first to the egg

Being First is a Game Changer

If you’re ahead of others, you become people’s go to person. It means more involvement. More challenge and opportunities to grow and network. Being first means you can pave the way for others and be helpful. It’s one of the key traits of a lead. Main Advantages of being first You can set the tone, guidelines that you want others to follow. And not you following others. Often you’re late into some bad architecture....

February 28, 2024 · 6 min

The effect of direction on recursion and understanding code

Today I’m going to discuss another fun and common challenge. It’s the Longest Common Subsequence a.k.a. LCS. I’ll first focus on discussing a pain point I went through when I was trying to compare the algorithm I deduced on my own vs a few other algorithms I saw online. Our algorithms seemed very similar. Yet different. It made debugging my code based on other code very difficult. This is a very common problem I face when I doing leetcode....

December 2, 2023 · 6 min
An AI generated image of asteroids

Asteroids Collision

Today we’re solving https://leetcode.com/problems/asteroid-collision/ Imagine if we had the following: 1 5 3 8 6 -> -> <- <- -> Each number represents the size of an asteroid. Each asteroid is either going left or right. Bigger asteroids destroy smaller asteroids. Asteroids with same size both get destroyed. If two asteroids are going in the same direction, they don’t hit each other, because all are going in the same speed....

November 20, 2023 · 6 min
Multiple envlopes along with their width and height

How Many Envelopes Can You Fit Into Another?

Question: How many envelops can you fit into another? Each envelope has a 2D representation. [4,5] -> width = 4, length = 5 How many envelops can you fit into one another without rotating any envelopes. Bare in mind you can’t fit in two evelopes with same width or height. This is question is very much like a Russian Doll question. Which that question itself uses an Longest increasing subsequence algorithm to solve....

November 12, 2023 · 4 min