How to resolve the algorithm Long year step by step in the Raku programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Long year step by step in the Raku programming language

Table of Contents

Problem Statement

Most years have 52 weeks, some have 53, according to ISO8601.

Write a function which determines if a given year is long (53 weeks) or not, and demonstrate it.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Long year step by step in the Raku programming language

Source code in the raku programming language

sub is-long ($year) { Date.new("$year-12-28").week[1] == 53 }

# Testing
say   "Long years in the 20th century:\n", (1900..^2000).grep: &is-long;
say "\nLong years in the 21st century:\n", (2000..^2100).grep: &is-long;
say "\nLong years in the 22nd century:\n", (2100..^2200).grep: &is-long;


  

You may also check:How to resolve the algorithm Queue/Definition step by step in the E programming language
You may also check:How to resolve the algorithm Substitution cipher step by step in the Ruby programming language
You may also check:How to resolve the algorithm Ethiopian multiplication step by step in the Bracmat programming language
You may also check:How to resolve the algorithm Calendar step by step in the SPL programming language
You may also check:How to resolve the algorithm Rename a file step by step in the C++ programming language