Sort by

recency

|

1510 Discussions

|

  • + 0 comments

    The "Day of the Programmer" is celebrated on the 256th day of the year, which usually falls on September 13th (or September 12th in leap years). This unique holiday honors programmers and developers, taking inspiration from the number 256, a significant value in computing. It’s the highest power of 2 that fits within a single byte (8 bits), making it a fitting representation through Convert inches for those who work with binary code and software development. The day is an opportunity to recognize the creativity, problem-solving skills, and innovations that programmers bring to the digital world.

  • + 0 comments

    For Java 15:

    private static boolean isLeap(int year){
        if(year < 1918){
            return year % 4 == 0;
        }
        return (year % 400 == 0) || (year%4==0 && year%100!=0);
    }
    
    public static String dayOfProgrammer(int year) {
        if(year == 1918){
            return "26.09."+year;
        }
        if(isLeap(year)){
            return "12.09."+year;
        } else {
            return "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

    python

    def dayOfProgrammer(year):
        if year==1918:
            return '26.09.1918'
        elif year > 1918 and ((int(year)%400==0) or (int(year)%4==0 and int(year)%100!=0)):
                return '12.09.'+str(year)
        elif year < 1918 and (int(year)%4==0):
            return '12.09.'+str(year)
        else:
            return '13.09.'+str(year)
    
  • + 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"; }