Perl Weekly Challenge #016

Task #1: Pythagoras Pie Puzzle

This puzzle’s connection with Pythagoras is tenuous indeed: it originally appeared in the Dutch magazine Pythagoras (see here and here)! But the puzzle is interesting. Of course, the real challenge is to work out the answer mathematically, but for those of us who are mathematically declined a Perl script is the way to go.

The first draft of my …

Perl Weekly Challenge #014

Challenge 1: Van Eck's sequence

I must admit I found the definition of the van Eck sequence hard to follow. The EXAMPLE at OEIS helped:

We start with a(1) = 0. 0 has not appeared before, so the rule says a(2) = 0. Now 0 HAS occurred before, at a(1), which is 1 term before, so a(3) = 1. 1 has not occurred before, so a(4) = 0. 0 appeared most recently at term a(2), which is 2 terms earlier, so a(5) = 2. 2 has not occurred before, so a(6) = 0. And so on…

Perl Weekly Challenge #013

Challenge 1: Write a script to print the date of the last Friday of every month in a given year

First thought was to use a module to look up the day of the week for the last day of each month in the given year, then work backwards (in each month) to get the last Friday. But — well, once the weekday of any day in the year is known, the rest can be calculated directly without a further module look-up.

Actually, no module look-up is really needed at all once the day-of-the-week of any day in any year is known. And since I know that 17th June, 2019…

About Athanasius

user-pic PerlMonk; experienced Perl5 hacker; learning Perl6.