Calendar Module HackerRank Solution

This Python script is designed to take a date as input and return the corresponding day of the week. It uses Python's built-in calendar and datetime modules to accomplish this task. The date is input as three integers representing the month, day, and year, respectively.

Secure your next interview 🎯

CodeRankGPT is a tool powered by GPT-4 that quietly assists you during your coding interview, providing the solutions you need.
In real-time and absolutely undetectable 🥷

Here is the Calendar Module HackerRank Solution HackerRank solution using CodeRankGPT:

The script works by first mapping the input to three integers representing the month, day, and year. These integers are then used to create a datetime object. The weekday method of the datetime object is then used to get the day of the week as an integer, where Monday is 0 and Sunday is 6. This integer is then used to index into the day_name array of the calendar module, which returns the name of the day as a string. The string is then converted to uppercase and printed.


import calendar
import datetime

m, d, y = map(int, input().split())
input_date = datetime.date(y, m, d)
print(calendar.day_name[input_date.weekday()].upper())

If you have a HackerRank coding test coming up, you can use CodeRankGPT to your advantage. It will assist you during your interview and help ensure you get the job.

AI is here now, and other candidates might be using it to get ahead and win the job. 🧐

Built on Unicorn Platform