We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Day of the Programmer
Day of the Programmer
Sort by
recency
|
1442 Discussions
|
Please Login in order to post a comment
another c++ sol:
string dayOfProgrammer(int year) { int d=0; int m=0; int y=year; if(y<1918) { if(y%4==0) { return ("12.09."+to_string(y)); } else { return("13.09."+to_string(y)); } } else if(y>1918) { if(y%400==0 || (y%4==0&&y%100!=0)) { return("12.09."+to_string(y)); } else{ return("13.09."+to_string(y)); }
} else{ return("26.09."+to_string(y)); } return "0"; }
Not doing anything fancy with the special 1918 case
OOP approach
Solution in C#:
Python: def dayOfProgrammer(year): return ('12.09.' if year<1918 and year%4==0 or (year%4==0 and year%100!=0 or year%400==0) else '26.09.' if year==1918 else '13.09.')+str(year)