Sort by

recency

|

1507 Discussions

|

  • + 0 comments

    Here's my java solution if(year>=1919 && year<=2700){ if(year%4==0 && (year%100!=0 || year%400==0)){ return 12+".09"+"."+year; }else{ return 13+".09"+"."+year; } }else if(year>=1700 && year<=1917){ if(year%4==0){ return 12+".09"+"."+year; }else{ return 13+".09"+"."+year; } }else{ return "26.09.1918"; }

  • + 1 comment

    JavaScript

    function dayOfProgrammer(year) {
        return ((year >= 1700 && year < 1918 && year % 4 == 0)
            || (year > 1918 && year <= 2700 && (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)))
            ? "12" : (year == "1918") ? "26" : "13") + ".09." + year;
    }
    
  • + 0 comments

    Here is my c++ solution, you can watch the explanation here : https://youtu.be/U1u7Zz4ngVg

    string dayOfProgrammer(int year) {
        if(year == 1918) return "26.09.1918";
        if( (year <= 1917 && year % 4 == 0) or (year > 1918) && (year%400 == 0 or ((year%4 == 0) & (year%100 != 0)))) return "12.09."+to_string(year);
        return "13.09." + to_string(year);
    }
    
  • + 0 comments

    java(8)

    public static String dayOfProgrammer(int year) {
        // Write your code here
    
        int[] leapYear = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
        int[] notLeapYear = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
    
        int month = 0;
        int sumOfDay = 0;
    
        if (year < 1919) {
    
            if (year % 4 == 0) {
    
                while (sumOfDay <= 256) {
    
                    sumOfDay += leapYear[month];
                    month++;
    
                }
                if (sumOfDay > 256) {
                    sumOfDay -= leapYear[month - 1];
                }
            } else if (year % 4 != 0) {
    
                while (sumOfDay <= 256) {
    
                    sumOfDay += notLeapYear[month];
                    month++;
                }
                if (sumOfDay > 256) {
                    sumOfDay -= notLeapYear[month - 1];
                }
    
            }
    
        }
    
        else if (year > 1918) {
            if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) {
                while (sumOfDay <= 256) {
    
                    sumOfDay += leapYear[month];
                    month++;
                }
                if (sumOfDay > 256) {
                    sumOfDay -= leapYear[month - 1];
                }
    
            } else {
    
                while (sumOfDay <= 256) {
    
                    sumOfDay += notLeapYear[month];
                    month++;
                }
                if (sumOfDay > 256) {
                    sumOfDay -= notLeapYear[month - 1];
                }
    
            }
        }
    
        int date = 256 - sumOfDay;
    
        String m;
        if (month < 12) {
            String fL = "0";
            m = fL + Integer.toString(month);
        } else {
            m = Integer.toString(month);
        }
        String d = Integer.toString(date);
        String y = Integer.toString(year);
    
        return d + "." + m + "." + y;
    
    }
    
  • + 0 comments

    can anybody explain to me how 2017 is a leap year but 2016 is not???