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

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Long year step by step in the Wren 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 Wren programming language

Source code in the wren programming language

import "./date" for Date

var centuries = ["20th", "21st", "22nd"]
var starts = [1900, 2000, 2100]
for (i in 0...centuries.count) {
    var longYears = []
    System.print("\nLong years in the %(centuries[i]) century:")
    for (j in starts[i]...starts[i]+100) {
        var t = Date.new(j, 12, 28)
        if (t.weekOfYear[1] == 53) {
            longYears.add(j)
        }
    }
    System.print(longYears)
}


  

You may also check:How to resolve the algorithm Function prototype step by step in the Racket programming language
You may also check:How to resolve the algorithm Enforced immutability step by step in the Delphi programming language
You may also check:How to resolve the algorithm Classes step by step in the C# programming language
You may also check:How to resolve the algorithm String matching step by step in the Swift programming language
You may also check:How to resolve the algorithm Ternary logic step by step in the Arturo programming language