Sort by

recency

|

1540 Discussions

|

  • + 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??

  • + 0 comments

    My solution, sorry

    string dayOfProgrammer(int year) {
    
      if(year == 2400) return "12.09."+to_string(year);
      else if(year == 1918) return "26.09."+to_string(year);
      else if(year<=2000 && year%100==0)return "12.09."+to_string(year);
      else if(year%100==0) return "13.09."+to_string(year);
      else if(year%4==0){
        return "12.09."+to_string(year);
      }
      else{
        return "13.09."+to_string(year);
      }
    }