## Find Dates

View as PDF

Points: 7
Time limit: 1.0s
Memory limit: 64M

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

I have a document full of dates that you need to process. I am really busy, so I need you to write a program for me to find all the dates. I only want valid dates, that is dates that actually exist, in the format YYYY-MM-DD exactly. Any date that does not fit exactly in YYYY-MM-DD or does not actually exist must be ignored. A valid date will also be have non-alphanumeric characters on both sides.

Note: Leap years are very important for me.

#### Input Specification

The first line is an integer , the number of lines in the input. The next lines will be the document you need to process.

#### Output Specification

You are to output all valid dates in the exact format YYYY-MM-DD inside the document.

#### Sample Input

4
Archduke Franz Ferdinand was killed on 1914-06-28. On 1914-07-28,
Austria-Hungary declared war on Serbia. Germany attacked Luxemburg on 08-02,
and war was declared on France on 1914-08-03. On 04-08-1914, Britain declared
war.

#### Sample Output

1914-06-28
1914-07-28
1914-08-03

• commented on Sept. 5, 2020, 3:47 p.m.

My output matches the sample output exactly (for TC 1). Is TC1 different than the sample?

• commented on Sept. 5, 2020, 4:01 p.m.
1. Yes, the test case is different from the sample (you can verify this by submitting the sample output in Text.)
2. Your logic for handling leap years is wrong.
• commented on Sept. 25, 2017, 7:49 p.m.

What am I missing? My date validation seems correct and since the dates can't be surrounded by alphanumeric characters, the word boundaries should be fine too.

• commented on June 9, 2015, 12:07 a.m.

Why does the judge crash with my submissions? It works perfectly fine when I use it at my own computer.

BTW I'm using VS2013 not code blocks so that might be different.

• commented on June 8, 2015, 10:11 p.m.

Does the order in which the dates are outputted matter?

• commented on June 9, 2015, 12:01 a.m.

Yes.

• commented on Jan. 30, 2015, 7:11 p.m.

I had to use this for reference.

;(

• commented on Dec. 7, 2014, 10:03 p.m.

The judge reports wrong answer back to me, but the output looks correct. Any tips on how to solve?

• commented on Dec. 8, 2014, 11:15 a.m.

Same issue here..

• commented on Dec. 8, 2014, 11:28 p.m.

Read the problem statement more carefully, as there's something you're missing.

• commented on Dec. 11, 2014, 12:46 a.m.

I see it now, it's the format of output

• commented on Dec. 13, 2014, 12:38 p.m.

Could you elaborate on that please?

• commented on Dec. 13, 2014, 12:56 p.m.

Carefully re-read the second sentence of the problem statement. There's something you're missing.

• commented on Dec. 7, 2014, 2:21 p.m.

Weird, it gives the right output and doesn't crash on my computer. But the judge says it gets out of bounds exception?

• commented on Dec. 7, 2014, 3:22 p.m.