ZLA
AST

Tag: coding

Project Euler # Problem 34 - Digit Factorials
This problem is interesting because we aren't given an upper limit as to where we should end our search. So how about we find it?
Read Time: 3 min
Posted: January 15, 2026
CodingMathPython
Project Euler # Problem 33 - Digit Cancelling Fractions
I took the most straightforward solution I could think of (cause I'm a straightforward kind of guy)
Read Time: 3 min
Posted: January 14, 2026
CodingMathPython
Project Euler # Problem 32 - Pandigital Products
The first thing to realize is that there are only two possibilities ✌️
Read Time: 3 min
Posted: March 31, 2024
CodingMathPython
Project Euler # Problem 31 - Coin Sums
I'll admit something: When I first solved this problem years ago, it almost broke me 😭.
Read Time: 6 min
Posted: March 17, 2024
CodingMathPython
Project Euler # Problem 30 - Digit Fifth Powers
This problem is interesting because it doesn't mention a scope. How do we know when to stop searching for numbers that can be written as the sum of the fourth/fifth power of their digits? I don't know myself, but I made some assumptions.
Read Time: 1 min
Posted: March 16, 2024
CodingMathPython
Project Euler # Problem 29 - Distinct Powers
I decided to go with the most straight-forward solution. (Oy vey πŸ’€)
Read Time: 1 min
Posted: March 15, 2024
CodingMathPython
Project Euler # Problem 28 - Number Spiral Diagonals
Let's notice a few things: In the first 'ring,' the numbers 3, 5, 7, and 9 go up by two. In the second 'ring,' the numbers 13, 17, 21, and 25 go up by four.
Read Time: 1 min
Posted: March 14, 2024
CodingMathPython
Project Euler # Problem 27 - Quadratic Primes
Why does #3 use only positive primes? Actually, it doesn't have to, but from observing the output, only the positive prime numbers produce chains, so we can do away with trying the negative side.
Read Time: 2 min
Posted: March 13, 2024
CodingMathPython
Project Euler # Problem 26 - Reciprocal Cycles
This solution involved a bit of research, but here are three Wikipedia pages that I found helpful: Full Reptend Primes, Multiplicative Order, and Cyclic Number.
Read Time: 3 min
Posted: March 12, 2024
CodingMathPython
Project Euler # Problem 25 - 1000-digit Fibonacci Number
Nothing complicated here. (I say stuff like this a lot don't I? Trust me, me not that smaht πŸ’€)
Read Time: 1 min
Posted: March 11, 2024
CodingMathPython
Project Euler # Problem 24 - Lexicographic Permutations
It ironically took more time to write this code than to get the answer from print(lex[999999]). Work hard to be lazy 😀
Read Time: 1 min
Posted: March 10, 2024
CodingMathPython
Project Euler # Problem 23 - Non-Abundant Sums
Phew, this problem is more involved than others, but manageable. Here are the steps I took to solve it.
Read Time: 5 min
Posted: March 9, 2024
CodingMathPython
Project Euler # Problem 22 - Names Scores
A fairly straightforward solution. Boy, a lot of these aren't there? 😱
Read Time: 1 min
Posted: March 8, 2024
CodingMathPython
Project Euler # Problem 21 - Amicable Numbers
To complete this problem, I needed some new code that would perform factorization. I decided to have two functions: one that returns the prime factors of a number and one that returns the proper divisors of a number.
Read Time: 1 min
Posted: March 7, 2024
CodingMathPython
Project Euler # Problem 20 - Factorial Digit Sum
Another simple problem. 😁
Read Time: 1 min
Posted: March 6, 2024
CodingMathPython
Project Euler # Problem 19 - Counting Sundays
Thank goodness for Python, as it makes this problem trivial. The question asks, 'How many Sundays fell on the first of the month during the twentieth century?'
Read Time: 1 min
Posted: March 5, 2024
CodingMathPython
Project Euler # Problem 18 - Maximum Path Sum I
It's easier to solve the problem by starting at the bottom and working towards the top. This allows us to have just one number at the end instead of a row of numbers. They say 'a picture is worth a thousand words,' so here's an animation of what the code will do.
Read Time: 2 min
Posted: March 4, 2024
CodingMathPython
Project Euler # Problem 17 - Number Letter Counts
The solutions is split into three sections. From there, it's combining these groups of words to make all the numbers from 1 to 999 (then appending one thousand to the end).
Read Time: 2 min
Posted: March 3, 2024
CodingMathPython
Project Euler # Problem 16 - Power Digit Sum
The solution I went for was fairly simple. 😁
Read Time: 1 min
Posted: February 3, 2024
CodingMathPython
Project Euler # Problem 15 - Lattice Paths
We can use combinatorics to solve this question! If we look at the grid, we always make a total of four moves in some combination of moving right and moving down. Of the four possible moves, we should choose two of them to be in a particular direction, say, towards the right. With that, we get '4 choose 2.'
Read Time: 5 min
Posted: February 2, 2024
CodingMathPython
Project Euler # Problem 14 - Longest Collatz Sequence
The solution is pretty straight-forward based on the problem description, but we can make an optimization.
Read Time: 2 min
Posted: February 1, 2024
CodingMathPython
Project Euler # Problem 13 - Large Sum
This problem was very straight forward 😁
Read Time: 1 min
Posted: January 31, 2024
CodingMathPython
Project Euler # Problem 12 - Highly Divisible Triangular Number
The problem asks us, 'What is the value of the first triangle number to have over five hundred divisors?'. This means we have to be able to find the number of divisors for any given number.
Read Time: 5 min
Posted: January 29, 2024
CodingMathPython
Project Euler # Problem 11 - Largest Product in a Grid
I start off by taking the number grid and turning it into a 2D array in Python. This way, I can access any number in the grid using [x][y] notation with x accessing the rows and y accessing the columns.
Read Time: 1 min
Posted: January 26, 2024
CodingMathPython
Project Euler # Problem 10 - Summation of Primes
We can once again use the Sieve of Eratosthenesas seen in Problem 3. Since the sieve returns a list (array), we can just sum the returned list.
Read Time: 1 min
Posted: October 7, 2023
CodingMathPython
Project Euler # Problem 9 - Special Pythagorean Triplet
In order to generate Pythagorean Triples we can use Euclid's Formula
Read Time: 2 min
Posted: October 6, 2023
CodingMathPythonRust
Project Euler # Problem 8 - Largest Product in a project
We have to multiply 13 adjacent digits and find the largest. To do this, we can use a β€œsliding window” to multiply an array of numbers.
Read Time: 1 min
Posted: October 5, 2023
CodingMathPython
Project Euler # Problem 7 - 10 001st Prime
Since we're generating primes, I'll be using the Sieve of Eratosthenes, which was seen and created in Problem 3.
Read Time: 2 min
Posted: October 2, 2023
CodingMathPython
Project Euler # Problem 6 - Sum Square Difference
The problem with this approach is that if we change the range, say from [1 - 100] to [1 - 1 000 000], it would take a much longer time to calculate. What if we could skip all this and have a much faster approach?
Read Time: 1 min
Posted: October 1, 2023
CodingMathPythonRust
Project Euler # Problem 5 - Smallest multiple
The solution involves what we have seen in previous problems: prime factorization. Let's look at the example given in the problem.
Read Time: 2 min
Posted: April 28, 2023
CodingMathPythonRust
Project Euler # Problem 4 - Largest palindrome product
The solution here may not be the most efficient, but it works. The program loops through all 3-digit number products, converts them to a string, reverses the string, and then checks if the reversed and unreversed strings are equivalent.
Read Time: 1 min
Posted: April 23, 2023
CodingMathPythonRust
Project Euler # Problem 3 - Largest prime factor
Every natural number, β„•, is either prime or can be created using prime numbers. For example, the number 2595 can be created using the prime numbers (factors) 3, 5, and 173.
Read Time: 3 min
Posted: April 22, 2023
CodingMathPython
Project Euler # Problem 2 - Even Fibonacci numbers
If you understand how a Fibonacci sequence works, then the code below is understandable. The solution has been written in both Python and Rust, and either one will work.
Read Time: 1 min
Posted: April 3, 2023
CodingMathPythonRust
nand2tetris # Project 4 - Machine Language
Here, we write some simple programs in the course's HACK assembly language.
Read Time: 5 min
Posted: April 2, 2023
CodingComputersDigital
Project Euler # Problem 1 - Multiples of 3 and 5
We have to find all the multiples of 3 or 5 below 1000 and get the sum. One thing to be careful of are multiples of 15, as they are multiples of both 3 and 5, and we want multiples of 3 or 5.
Read Time: 1 min
Posted: March 28, 2023
CodingMathPythonRust
nand2tetris # Project 3 - Memory
Here, we create the memory modules for the computer.
Read Time: 5 min
Posted: February 14, 2023
CodingComputersDigital
nand2tetris # Project 2 - The ALU
This is the continuation of the previous post, Project 2 - Boolean Arithmetic. In this post, only the Arithmetic Logic Unit (ALU) is created, but it is deserving of its own writeup as there is a lot packed into this section that needs examining.
Read Time: 10 min
Posted: January 23, 2023
CodingComputersDigital
nand2tetris # Project 2 - Boolean Arithmetic
If we're going to build a computer, we'll have to be able to perform some boolean arithmetic. This post is dedicated to the creation of four 'chips' that do just that, though all of them perform only addition is some way.
Read Time: 5 min
Posted: January 22, 2023
CodingComputersDigital
nand2tetris # Project 1 - Basic Gates and Chips
In an effort to design a simple computer from the ground up, we need to create the relevant hardware to make such a machine work.
Read Time: 10 min
Posted: January 21, 2023
CodingComputersDigital