Day of week that is K days later

Given current day as day of the week and an integer K, the task is to find the day of the week after K days.

Example 1:

Input:

day = “Monday”

K = 3

Output: Thursday

Example 2:

Input:

day = “Tuesday”

K = 101

Output: Friday

Try it yourself

Implementation

1
1
def dayOfWeek(day, k) -> str:
2
-
      # WRITE YOUR BRILLIANT CODE HERE
2
+
      days = [ "Monday",
3
+
               "Tuesday",
4
+
               "Wednesday",
5
+
               "Thursday",
6
+
               "Friday",
7
+
               "Saturday",
8
+
               "Sunday" ]
9
+
      index = 0
10
+
      for i in range(len(days)):
11
+
          if days[i] == day:
12
+
              index = i
13
+
      return days[(index + k) % 7]
3
14
if __name__ == '__main__':
4
15
    print(dayOfWeek(input(), int(input())))