Sort by

recency

|

1557 Discussions

|

  • + 0 comments

    C++

    bool is_julian(int year) {
        return (year % 4 == 0);
    }
    
    bool is_gregorian(int year) {
        return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
    }
    
    string additional_zero(int n) {
        return (n < 10 ? "0" + to_string(n) : to_string(n));
    }
    
    string dayOfProgrammer(int year) {
        vector<int> month_days = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
        int month = 0;
        int year_day = 256;
        
        if (year == 1918) {
            year_day += 13;
        } else if (year >= 1919) {
            if (is_gregorian(year)) {
                month_days[1] = 29;
            }
        } else {
            if (is_julian(year)) {
              month_days[1] = 29;
            }
        }
    
        while (year_day > month_days[month]) {
            year_day -= month_days[month];
            month++;
        }
        month += 1;
    
        return additional_zero(year_day) + "." + additional_zero(month) + "." + to_string(year);
    }
    
  • + 0 comments

    The Day of the Programmer celebrates innovation, problem-solving, and the continuous pursuit of knowledge — values that truly resonate with us at Ocentra Training Center. We believe in empowering learners with the technical and creative skills needed to thrive in the digital era.

  • + 0 comments

    in 1918, when the next day after January 31st was February 14th. This means that in 1918, February 14th (45th day) was the 32nd day of the year in Russia.

    It means we cut 13 days, that shifts the Day X to later date.

  • + 1 comment

    Day of the programmer Solution [PYTHON] :

    def dayOfProgrammer(year):
        # Write your code here
    if year < 1918:
        if year % 4 == 0:
            result = ("12.09." + str(year))
        else:
            result = ("13.09." + str(year))
    elif year == 1918:
        result = ("26.09.1918")
    else:
        if year % 400 == 0 or (year % 100 != 0 and year % 4 == 0):
            result = ("12.09." + str(year))
        else:
            result = ("13.09." + str(year))
    return result
    
  • + 0 comments
    string dayOfProgrammer(int year)
    {
        int totalDays = 215;
        bool leapYear = false;
        if(year < 1918)
        {
            //Julian calendar
            if(year%4 == 0)
            {
                leapYear = true;
            }
        }
        else if(year > 1918)
        {
            //Gregorian calendar
            if(year%400 == 0 || (year%4 == 0 && year%100 != 0))
            {
                leapYear = true;
            }
        }
        else
        {
            //Julian-Gregorian transition calendar
            totalDays += 15;
        }
        if(leapYear)
        {
            totalDays += 29;
        }
        else if(year != 1918)
        {
            totalDays += 28;
        }
        string sepDate = to_string(256 - totalDays);
        sepDate += ".09.";
        return (sepDate += to_string(year));
    }