How to resolve the algorithm Find the last Sunday of each month step by step in the Raku programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Find the last Sunday of each month step by step in the Raku programming language
Table of Contents
Problem Statement
Write a program or a script that returns the last Sundays of each month of a given year. The year may be given through any simple input method in your language (command line, std in, etc). Example of an expected output:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Find the last Sunday of each month step by step in the Raku programming language
Source code in the raku programming language
sub MAIN ($year = Date.today.year) {
for 1..12 -> $month {
my $month-end = Date.new($year, $month, Date.new($year,$month,1).days-in-month);
say $month-end - $month-end.day-of-week % 7;
}
}
You may also check:How to resolve the algorithm Tokenize a string with escaping step by step in the 8080 Assembly programming language
You may also check:How to resolve the algorithm Short-circuit evaluation step by step in the M2000 Interpreter programming language
You may also check:How to resolve the algorithm Integer sequence step by step in the ERRE programming language
You may also check:How to resolve the algorithm Simple windowed application step by step in the Modula-3 programming language
You may also check:How to resolve the algorithm Hello world/Graphical step by step in the REBOL programming language