Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
25
Task/Palindrome-dates/Jq/palindrome-dates.jq
Normal file
25
Task/Palindrome-dates/Jq/palindrome-dates.jq
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
# input and output: [year, month, day] using month=1 for Jan
|
||||
# add the number of days to the input date
|
||||
def addDays($days):
|
||||
. as [$y,$m,$d]
|
||||
| [$y,$m-1,$d + $days,0,0,0,0,0] | mktime | gmtime[0:3] | .[1]+=1;
|
||||
|
||||
# input: [year, month, day], an array of integers
|
||||
# output: [yyyy, mm, dd] , an array of strings,
|
||||
def yyyymmdd:
|
||||
def l($len): tostring | ($len - length) as $l | ("0" * $l)[:$l] + .;
|
||||
[(.[0]|l(4)), (.[1]|l(2)), (.[2]|l(2))] ;
|
||||
|
||||
# input: [year, month, day] using month=1 for Jan
|
||||
def isPalDate:
|
||||
yyyymmdd | add | explode | . == reverse;
|
||||
|
||||
def task:
|
||||
"The next 15 palindromic dates in yyyy-mm-dd format after 2020-02-02 are:",
|
||||
( [2020, 2, 2]
|
||||
| addDays(1)
|
||||
| limit(15; recurse(addDays(1)) | select(isPalDate) )
|
||||
| yyyymmdd
|
||||
| join("-") );
|
||||
|
||||
task
|
||||
Loading…
Add table
Add a link
Reference in a new issue