Você está na página 1de 2

14/07/2017 TCS: CodeVita - Coding Arena

TCS NextStep TCS Careers www.tcs.com Logout

Welcome Home Coding Arena Compile & Run Submissions Graphs Feedback

Time Left

Coding Arena 00 00 00
Change Default Language hr min sec

A B C D E F

Rules & Regulations


Problem : Digital Time
Launch Code Editor
The objective is to form the maximum possible time in the HH:MM:SS format using any six of nine given single digits (not
necessarily distinct)
Notifications

Given a set of nine single (not necessarily distinct) digits, say 0, 0, 1, 3, 4, 6, 7, 8, 9, it is possible to form many distinct times
in a 24 hour time format HH:MM:SS, such as 17:36:40 or 10:30:41 by using each of the digits only once. The objective is to Status messages
find the maximum possible valid time (00:00:01 to 24:00:00) that can be formed using some six of the nine digits exactly
once. In this case, it is 19:48:37.

Input

A line consisting of a sequence of 9 (not necessarily distinct) single digits (any of 0-9) separated by commas. The sequence will
be non-decreasing

Output

The maximum possible time in a 24 hour clock (00:00:01 to 24:00:00) in a HH:MM:SS form that can be formed by using some
six of the nine given digits (in any order) precisely once each. If no combination of any six digits will form a valid time, the
output should be the word Impossible

Example 1

Input:

0,0,1,1,3,5,6,7,7

Output:

17:57:36

Explanation:

The maximum valid time in a 24 hour clock that can be formed using some six of the 9 digits precisely once is 17:57:36

Example 2

Input:

3,3,3,3,3,3,3,3,3

Output:

Impossible

Explanation:

No set of six digits from the input may be used to form a valid time.

Note:

Please do not use package and namespace in your code. For object oriented languages your code should be written in one
class.
Note:

Participants submitting solutions in C language should not use functions from <conio.h> / <process.h> as these files do not
exist in gcc
Note:

For C and C++, return type of main() function should be int.

© 2017 Tata Consultancy Services Limited. All Rights Reserved.

Submit Answer

I ,confirm that the answer submitted is my own.I would like to


provide attribution to the following sources.

http://www.tcscodevita.com/CodevitaV6/problemstart.jsp 1/2
14/07/2017 TCS: CodeVita - Coding Arena

Select Language
Select File
Browse...

© 2017 Tata Consultancy Services Limited. All Rights Reserved. In Association with | Privacy Policy

http://www.tcscodevita.com/CodevitaV6/problemstart.jsp 2/2

Você também pode gostar