Browse category PHP Puzzles
PHP Puzzles: Decimals to Fractions
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
PHP Puzzles: The Birthday Paradox
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
PHP Puzzles: Clues for Hues
In the last two months, we saw how to control randomness. This month, we let users guess the random sequence created by the program.
PHP Puzzles: Making Some Change
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?
PHP Puzzles: Finding Prime Factors
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.
PHP Puzzles: Finding Integer Factors
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
PHP Puzzles: Infamous Fizz Buzz
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
PHP Puzzles: Breakeven Point
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
PHP Puzzles: Compounding Interest
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 […]