Sort by

recency

|

1541 Discussions

|

  • + 1 comment

    For most years, the Day of the Programmer falls on 13.09.yyyy, but if it’s a leap year, it’s 12.09.yyyy. For the year 1918, due to the calendar change in Russia, the date is 26.09.1918. Cloud-Anbindung Azure

  • + 0 comments

    Happy Day of the Programmer! To all the brilliant minds behind the code, your creativity fuels innovation. Whether you are debugging or deploying, your impact is huge. And if you are thinking of upgrading your Mac for better performance, check out Dubai’s Trusted Mac Experts for smooth and reliable device resale!

  • + 0 comments
    def dayOfProgrammer(year):
        # Write your code here
        if year == 1918:
            return "26.09.1918"
            
        is_leap_year = False
        
        if year <= 1917:
            is_leap_year = year % 4 == 0
            
        else:
            is_leap_year = year % 400 == 0 or (year % 4 == 0 and year % 100 != 0)
            
        return f"12.09.{year}" if is_leap_year else f"13.09.{year}"
    
  • + 0 comments

    rust

    fn day_of_programmer(year: i32) -> String {
        let mut days_of_month: [usize; 12] = [31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
        days_of_month[1] = match year {
            1700..=1917 => if year % 4 == 0 { 29 } else { 28 }, // julian
            1919..=2700 => if year % 400 == 0 || (year % 4 == 0 && year % 100 != 0) { 29 } else { 28 }, // gregorian
            1918 => 15, // transition year
            _ => panic!("time traveler error")
        };
        let mut days = 256usize;
        let mut i = 0usize;
        while days > days_of_month[i] {
            days -= days_of_month[i];
            i += 1;
        }
        format!("{:02}.{:02}.{year}", days, i+1)
    }
    
  • + 0 comments

    Why are Hackerrank problems so hard to understand of what is actually being asked to do! Am I the only one??