Last active
June 13, 2017 12:19
-
-
Save Ern-st/645bf5b5c6cd88c838c2d034342e254e to your computer and use it in GitHub Desktop.
assignment: find the next 3 years, where the 1. May is on a saturday or sunday.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//<script> | |
var year = 2016; | |
var free = 0; | |
var start_day = "sun"; | |
var days = ["sun","mon","tue","wed","thu","fri","sat"]; | |
var carry = 0; | |
year++; | |
while(free != 3){ | |
carry = (carry + days_in_year(year)) % 7 | |
if (carry % 6 == 0 || carry % 0 == 0) { | |
console.log(year+" weekday: "+days[carry]); | |
free += 1; | |
}; | |
year += 1; | |
} | |
function days_in_year(year){ | |
if(year % 4 == 0 && (year % 100 !== 0 || year % 400 == 0)){ | |
return 366 | |
} else { | |
return 365 | |
} | |
} | |
//</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment