Sort by

recency

|

651 Discussions

|

  • + 0 comments

    It gives flexibility for regional or personal preferences, which is a nice touch. Overall, it looks like a great module for anyone dealing with dates, schedules, or just needing a quick way to visualize time. https://cricbet99.club

  • + 0 comments

    OMG didn't know cal.day_name exists, I wrote the following code

    import calendar
    import re 
    
    def find_the_day(date):
      
        month, day, year = date.split()
        months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'June', 'July', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
        dotws = [x.upper() for x in ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']]
        
      
        dates = calendar.TextCalendar(firstweekday = 7).formatyear(int(year)).split('\n\n')
        rmonth = months[int(month) -1]
            
        for x in dates:
            if rmonth in x:
                weeks = x.split('\n')
                
        week = [re.split('\s{3,}', week) for week in weeks]
        week = [x for y in week for x in y if re.search('[0-9]', x)]
        
        targets = week[int(month)%3-1 : len(week) : 3]
    
        for i in range(len(targets)):
            if int(day) in map(int, targets[i].split()):
                target = map(int,targets[i].split())
        
        if str(1) != day:
            dotw = dotws[list(target).index(int(day))]
        else:
            dotw = dotws[-(list(target).index(int(day))+1)]
        
        return dotw
    		print(dotw)
    

    Although it works fine in jupyter notebook, I don't see why it doesn't work withint Hackers environment, does anybody know what the problem is?

    althoug

  • + 0 comments

    Short and sweet!:

    import calendar as cal m, d, y = map(int, input().split()) print(cal.day_name[cal.weekday(y, m, d)].upper())

  • + 0 comments
    # Enter your code here. Read input from STDIN. Print output to STDOUT
    import calendar
    m, d, y = input().split()
    # day_index = calendar.weekday(int(y), int(m), int(y))
    y, m, d = int(y), int(m), int(d)
    day_index = calendar.weekday(y, m, d)
    days_of_week = list(calendar.day_name)
    print(days_of_week[day_index].upper())
    
  • + 0 comments

    import calendar

    M,D,Y=input().split() year=int(Y) month=int(M) day=int(D) out=calendar.weekday(year,month,day) days=list(calendar.day_name)

    print(days[out].upper())