Publications by Peter Prevos
Euler Problem 18 & 67: Maximum Path Sums
An example of a pedigree. Source: Wikimedia. Euler Problem 18 and 67 are exactly the same besides that the data set in the second version is larger than in the first one. In this post, I kill two Eulers with one code. These problems deal with binary trees, which is a data structure where each node has two children. A practical example of a binary...
2932 sym R (1577 sym/2 pcs) 2 img
Euler Problem 19: Counting Sundays — When does the week start?
Euler Problem 19 is so trivial it is almost not worth writing an article about. One interesting aspect of this problem is the naming of weekdays and deciding which day the week starts. This issue is more complex than it sounds because data science is in essence not about data but about people. Euler Problem 19 Definition 1 Jan 1900 was a Monday...
2530 sym R (872 sym/2 pcs)
Euler Problem 20: Large Integer Factorials
Euler Problem 20 is the third problem that requires special consideration for working with very large integers. In this problem, we look at factorials. These numbers are useful in combinatorics if, for example, you like to know in how many ways you can arrange a deck of cards. The problem with computing factorials is that they are mostly very la...
3087 sym R (529 sym/3 pcs) 14 img
Euler Problem 21: Amicable Numbers
Euler problem 21 takes us to the realm of amicable numbers, which are listed in sequence A259180 in the OEIS. Amicable, or friendly, numbers are the most romantic numbers known to maths. Amicable numbers serve absolutely no practical purpose, other than mathematical entertainment. A related concept is a perfect number, which is a number that eq...
2283 sym R (658 sym/1 pcs) 22 img
Euler Problem 22 : Names Scores
R logo in ASCII art by picascii.com Euler problem 22 is another trivial one that takes us to the realm of ASCII codes. ASCII is a method to convert symbols into numbers, originally invented for telegraphs. Back in the 8-bit days, ASCII art was a method to create images without using lots of memory. Each image consists of a collection of text ch...
2061 sym R (968 sym/2 pcs) 2 img
The Sierpinski Triangle: Visualising infinity in R
Wacław Sierpiński was a mathematical genius who developed several of the earliest fractals. The Sierpiński triangle is an easy to conceptualise geometrical figure but it hides a fascinating mathematical complexity. Start by drawing an equilateral triangle and draw another one in its centre. Then draw equilateral triangles in the four resulti...
2484 sym R (449 sym/1 pcs) 2 img
Euler Problem 23: Non-Abundant Sums
A demonstration of the abundance of the number 12 using Cuisenaire rods (Wikipedia). Euler problem 23 asks us to solve a problem with abundant or excessive numbers. These are numbers for which the sum of its proper divisors is greater than the number itself. 12 is an abundant number because the sum of its proper divisors (the aliquot sum) is l...
2864 sym R (779 sym/2 pcs) 2 img
Tic Tac Toe Part 3: The Minimax Algorithm
In two previous posts, I presented code to teach R to play the trivial game of Tic Tac Toe. I thought this was an unbeatable algorithm. Alas, a comment from Alberto shattered my pride as he was able to beat my code. The reason for the demise of my code was that I didn’t implement a full minimax algorithm, but instead looked only two moves ahead...
2867 sym R (3727 sym/4 pcs) 4 img
Lexicographic Permutations: Euler Problem 24
Euler Problem 24 asks to develop lexicographic permutations which are ordered arrangements of objects in lexicographic order. Tushar Roy of Coding Made Simple has shared a great introduction on how to generate lexicographic permutations. Euler Problem 24 Definition A permutation is an ordered arrangement of objects. For example, 3124 is one poss...
2441 sym R (1004 sym/2 pcs) 30 img
Large integers in R: Fibonacci number with 1000 digits, Euler Problem 25
The Fibonacci Sequence occurs in nature: The nautilus shell. Euler Problem 25 takes us back to the Fibonacci sequence and the problems related to working with very large integers. The Fibonacci sequence follows a simple mathematical rule but it can create things of great beauty. This pattern occurs quite often in nature, like to nautilus shell ...
2183 sym R (649 sym/3 pcs) 10 img