Oscar Merida

twitter: @omerida


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 Final 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