How to resolve the algorithm Find the last Sunday of each month step by step in the J 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 J 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 J programming language
Source code in the j programming language
require'dates'
last_sundays=: 12 {. [: ({:/.~ }:"1)@(#~ 0 = weekday)@todate (i.366) + todayno@,&1 1
last_sundays 2013
2013 1 27
2013 2 24
2013 3 31
2013 4 28
2013 5 26
2013 6 30
2013 7 28
2013 8 25
2013 9 29
2013 10 27
2013 11 24
2013 12 29
You may also check:How to resolve the algorithm Roman numerals/Encode step by step in the Forth programming language
You may also check:How to resolve the algorithm Forward difference step by step in the ALGOL 68 programming language
You may also check:How to resolve the algorithm Symmetric difference step by step in the Ksh programming language
You may also check:How to resolve the algorithm Unicode strings step by step in the LFE programming language
You may also check:How to resolve the algorithm Jaro-Winkler distance step by step in the Julia programming language