How to resolve the algorithm Palindrome dates step by step in the J programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Palindrome dates step by step in the J programming language
Table of Contents
Problem Statement
Today (2020-02-02, at the time of this writing) happens to be a palindrome, without the hyphens, not only for those countries which express their dates in the yyyy-mm-dd format but, unusually, also for countries which use the dd-mm-yyyy format.
Write a program which calculates and shows the next 15 palindromic dates for those countries which express their dates in the yyyy-mm-dd format.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Palindrome dates step by step in the J programming language
Source code in the j programming language
task=: {{
r=. ''
days=. todayno 2020 02 02
while. 15 > #r do.
days=. ({:days)+1+i.1e4
r=. r, days#~(-:|.)"1":,.1 todate days
end.
15 10{.isotimestamp todate r
}}
task''
2021-12-02
2030-03-02
2040-04-02
2050-05-02
2060-06-02
2070-07-02
2080-08-02
2090-09-02
2101-10-12
2110-01-12
2111-11-12
2120-02-12
2121-12-12
2130-03-12
2140-04-12
You may also check:How to resolve the algorithm Averages/Median step by step in the BBC BASIC programming language
You may also check:How to resolve the algorithm Verify distribution uniformity/Naive step by step in the RPL programming language
You may also check:How to resolve the algorithm Zebra puzzle step by step in the Curry programming language
You may also check:How to resolve the algorithm Perfect totient numbers step by step in the Rust programming language
You may also check:How to resolve the algorithm One-dimensional cellular automata step by step in the jq programming language