We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. Prepare
  2. Python
  3. Date and Time
  4. Calendar Module
  5. Discussions

Calendar Module

Problem
Submissions
Leaderboard
Discussions
Editorial

Sort 552 Discussions, By:

recency

Please Login in order to post a comment

  • joshuabdeckard
    2 days ago+ 0 comments
    import calendar
    
    # collect information about mm, dd, and yy while converting into integers
    mm, dd, yy = (int(i) for i in input().split())
    
    
    # Returns the day of the week. Monday is zero.
    weekday = calendar.weekday(yy,mm,dd)
    
    # day_name takes an array and returns the name of the weekday associated with the value inside of our array.
    # It can not return multiple weekdays. 
    # I.E our array cannot have multiple values inside of it
    
    print(calendar.day_name[weekday].upper())
    
    0|
    Permalink
  • 404NameNotFound
    2 weeks ago+ 1 comment

    Another oneliner, (year > 2000)

    print( (lambda m, d, y: ['SATURDAY', 'SUNDAY', 'MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY'][int((int(d)+[0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365][int(m) - 1]-(not int(y)%4 and int(m)<3)+(int(y)-2000)*365.25)%7)])(*input().split()) )

    0|
    Permalink
  • babun012378910
    3 weeks ago+ 0 comments

    Enter your code here. Read input from STDIN. Print output to STDOUT

    import calendar import datetime date_time = input().split() month = date_time[0] day = date_time[1] year = date_time[2]

    day_number = calendar.weekday(int(year), int(month), int(day)) day_name = calendar.day_name[day_number] print(day_name.upper())

    0|
    Permalink
  • lucasopoka
    4 weeks ago+ 0 comments
    import calendar
    mm, dd, yy = map(int, input().split())
    print(calendar.day_name[calendar.weekday(yy,mm,dd)].upper())
    
    0|
    Permalink
  • lasanranatunge
    4 weeks ago+ 0 comments

    ---------------------------------------MY SOLUTION--------------------------------------

    1. Assign values to three vars (day, month, year) using string index.
    2. Store the calendar in a variable. cal = calendar.weekday(year, month, day)
    3. Create a list to hold days of the week starting from monday. (0th element is monday).
    4. Iterate over the list elements and print out the respective list element which is equal to the value in cal variable https://colab.research.google.com/drive/12QEMyeN8SyuFAxjwgKdLcqMm__0gV5rT?usp=sharing
    0|
    Permalink
Load more conversations

Need Help?


View editorial
View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy