Oscar Merida

twitter: @omerida


PHP Puzzles: Maze Rats

By Oscar Merida

Back in the January 2021 installment for PHP Puzzles, Sherri Wheeler
looked at drawing a path through a grid. In this first part, we delve
into the work of maze generation. by Oscar Merida

Published in Getting TEKnical, April 2023

PHP Puzzles: Grade Deviations

By Oscar Merida

We’re continuing with grades and statistics by calculating statistics for Grade Point Averages. In the educational system in the United States, it’s a way to boil down the grades across the multiple courses taken by a student. It involves translating a letter grade back to a numeric value and then calculating a weighted average. At the end of all this, we’re left with a singular number we can use for a rough comparison between students. by Oscar Merida

Published in Box of PHP, March 2023

PHP Puzzles: Stats 101 Grade Book

By Oscar Merida

Let’s go back to basics and look at some different ways to measure the average value in a list of numbers. More specifically, they’re ways of measuring central tendency. These handy techniques to identify “the middle” of a set prove useful when analyzing sales, traffic, or other frequency counts. by Oscar Merida

Published in Knowledge Crunching, February 2023

PHP Puzzles: Any Two Birthdays

By Oscar Merida

Working with dates and times is fraught with peril, so it helps to practice manipulating such data. We’ll have to be wary of how to calculate differences between dates, potentially deal with leap days, and other irregularities. by Oscar Merida

Published in PHP is Standing Tall, January 2023

PHP Puzzles: Sticker Swapping

By Oscar Merida

The FIFA World Cup wraps up this month. One thing many fans worldwide do in the months leading up to the tournament is to fill out sticker albums with each team’s roster. Completing an album, short of spending a ton of excess money, involves trading with other collectors. A common technical interview question is to find the common characters in a string or the common elements in multiple arrays. Let’s take a look at how to approach such a problem. by Oscar Merida

Published in Owning The Web, December 2022

PHP Puzzles: World Cup Draws

By Oscar Merida

A random draw is straightforward, but we usually have business rules to implement and consider in any solution. With the World Cup kicking off this month, we get a chance to look at one scenario. Can you draw the teams into proper groups before the tournament starts? by Oscar Merida

Published in The Value of the AST, November 2022

PHP Puzzles: Converting Float Strings

By Oscar Merida

Converting data is never as straightforward as we’d initially expect. Users can enter data incorrectly or in the wrong format. On the other hand, computers may not have trouble working with some data. For this article, we look again at floating-point values. by Oscar Merida

Published in The State of PHP, October 2022

PHP Puzzles: Fractional Math

By Oscar Merida

We’ve seen how working with floating-point values can be problematic. What if we had a class that worked with fractions directly by tracking the numerator and denominator as integers? Let’s see if it’s possible. by Oscar Merida

Published in Making Code, September 2022

PHP Puzzles: Decimals to Fractions

By Oscar Merida

In this installment, we look again at working with floating-point values. We approach how to take a decimal number and represent it as a fraction. by Oscar Merida

Published in PHP Blueprint, August 2022

PHP Puzzles: The Birthday Paradox

By Oscar Merida

We look at a solution to a problem that is not intuitive at first glance—the birthday paradox. Instead of calculating probabilities directly, we’ll use a simple simulation to solve the problem. by Oscar Merida

Published in Database Freedom, July 2022

PHP Puzzles: Clues for Hues

By Oscar Merida

In the last two months, we saw how to control randomness. This month, we let users guess the random sequence created by the program.

Published in Another Bright Idea, June 2022

PHP Puzzles: Controlled Randomness

By Oscar Merida

PHP Puzzles: Controlled Randomness

Published in One Last Slice, May 2022

PHP Puzzles: Making Some Change

By Oscar Merida

This article looks at a practical math problem most developers are likely to run into at some point. We’re given some amount of money and asked to figure out how to distribute it. Did you remember that computers are not very good at floating-point math?

Published in Testing The Core, April 2022

PHP Puzzles: Finding Prime Factors

By Oscar Merida

We’re building on a previous puzzle for finding integer factors. In this article, we look at how to find prime factors before turning to one more puzzle involving integer division.

Published in World Backup Day, March 2022

PHP Puzzles: Finding Integer Factors

By Oscar Merida

This article looks at solutions for finding integer factors for a given integer. Another way to put this problem is to decompose an integer into a multiple of two smaller integers. Besides hearkening back to Algebra classes of yore, we’ll discuss applications of this technique. by Oscar Merida

Published in Parallelize Your Code, February 2022

PHP Puzzles: Infamous Fizz Buzz

By Oscar Merida

Let’s start the year looking at a classic interview question—Fizz Buzz. It’s misused to screen applicants and may not be testing for what it thinks it is. Nonetheless, it doesn’t hurt to be prepared if you encounter it. We’ll look at various approaches to solve it. by Oscar Merida

Published in Domain-Driven Resolutions, January 2022

PHP Puzzles: Breakeven Point

By Oscar Merida

This month we are moving on from shifting money around time to focusing on costs at a specific moment in time. Join me as we tackle the break-even problem from last month. But first, we’ll step through it, analyzing it algorithmically to design our solution. by Oscar Merida

Published in The Zen of Mindful Programming, December 2021

PHP Puzzles: Compounding Interest

By Oscar Merida

Last month, we looked at how to output an amortization table to see how compounding interest affects some amount of money. Printing out such a table assumes we have a certain set of inputs. Moreover, it’s tedious, even simple for a computer to do. Let’s look at other ways to calculate the time value of money. by Oscar Merida

Published in The Art of Data, November 2021 —Available for Free

PHP Puzzles: Time Value of Money

By Oscar Merida

Is it better to get $100 today or $110 in one years time? The answer’s not straightforward because you could use $100 today to potentially earn more than $10 over 12 months. How do you know what to do? For that, you need to know how to calculate a rate of return or use it to compare amounts of money at different times. Hold on for a bit, we’re bending the time—space (money?) continuum.

Published in Decrypting Cryptography, October 2021

PHP Puzzles: Sending and Receiving Polybius Ciphers

By Oscar Merida

Ciphers come in many different forms and have been used since ancient times to encode and decode vital messages. Today, we use complicated mathematics to encrypt and decrypt messages. Typically, we depend on shared and secret keys to ensure the message is only readable by the intended recipients. What if you don’t have the computing power of a modern device at your disposal? This month, let’s look at using Polybius Squares to share secret messages.

Published in Testing Assumptions, May 2021

Streamlining Behat

By Oscar Merida

Behat, and feature tests overall, are crucial for giving you confidence that when you refactor code, you don’t change how an application works and for helping you understand how an application behaves in practice. Investing in integration and functional tests is worth it in the long term, and in this article, we’ll see how I also updated my Behat setup to run browser tests in Chrome.

Published in Testing Assumptions, May 2021 —Available for Free