#K82537. Next Working Day Calculator
Next Working Day Calculator
Next Working Day Calculator
Given a date in the format \(YYYY-MM-DD\) and a list of integers indicating non-working days for the week (where 0 represents Monday and 6 represents Sunday), your task is to determine the next working day. Starting from the day immediately following the given date, find the first date whose day-of-week is not in the non-working days list.
The input consists of the initial date, the number of non-working days, and the non-working day indices. The output is the next valid working day, formatted as \(YYYY-MM-DD\). For example, if the input date is 2023-06-23
(a Friday) and the non-working days are Saturday and Sunday (indices 5 and 6), the next working day will be Monday, 2023-06-26
.
inputFormat
The input is read from standard input (stdin) and has the following format:
<date> <n> <d1 d2 ... dn>
Where:
<date>
is a string representing the date in the format \(YYYY-MM-DD\).<n>
is an integer representing the number of non-working days.<d1 d2 ... dn>
are the non-working day indices (0 for Monday, 1 for Tuesday, ..., 6 for Sunday), separated by spaces.
outputFormat
The output is written to standard output (stdout) and consists of a single line containing the next working day in the format \(YYYY-MM-DD\).
## sample2023-06-23
2
5 6
2023-06-26