Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
40
Task/Five-weekends/CoffeeScript/five-weekends-1.coffee
Normal file
40
Task/Five-weekends/CoffeeScript/five-weekends-1.coffee
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
startsOnFriday = (month, year) ->
|
||||
# 0 is Sunday, 1 is Monday, ... 5 is Friday, 6 is Saturday
|
||||
new Date(year, month, 1).getDay() == 5
|
||||
|
||||
has31Days = (month, year) ->
|
||||
new Date(year, month, 31).getDate() == 31
|
||||
|
||||
checkMonths = (year) ->
|
||||
month = undefined
|
||||
count = 0
|
||||
month = 0
|
||||
while month < 12
|
||||
if startsOnFriday(month, year) and has31Days(month, year)
|
||||
count += 1
|
||||
console.log year + ' ' + month + ''
|
||||
month += 1
|
||||
count
|
||||
|
||||
fiveWeekends = ->
|
||||
startYear = 1900
|
||||
endYear = 2100
|
||||
year = undefined
|
||||
monthTotal = 0
|
||||
yearsWithoutFiveWeekends = []
|
||||
total = 0
|
||||
year = startYear
|
||||
while year <= endYear
|
||||
monthTotal = checkMonths(year)
|
||||
total += monthTotal
|
||||
# extra credit
|
||||
if monthTotal == 0
|
||||
yearsWithoutFiveWeekends.push year
|
||||
year += 1
|
||||
console.log 'Total number of months: ' + total + ''
|
||||
console.log ''
|
||||
console.log yearsWithoutFiveWeekends + ''
|
||||
console.log 'Years with no five-weekend months: ' + yearsWithoutFiveWeekends.length + ''
|
||||
return
|
||||
|
||||
fiveWeekends()
|
||||
30
Task/Five-weekends/CoffeeScript/five-weekends-2.coffee
Normal file
30
Task/Five-weekends/CoffeeScript/five-weekends-2.coffee
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
1901 2
|
||||
1902 7
|
||||
1903 4
|
||||
1904 0
|
||||
1904 6
|
||||
1905 11
|
||||
1907 2
|
||||
1908 4
|
||||
1909 0
|
||||
1909 9
|
||||
1910 6
|
||||
1911 11
|
||||
1912 2
|
||||
1913 7
|
||||
1914 4
|
||||
1915 0
|
||||
1915 9
|
||||
1916 11
|
||||
1918 2
|
||||
1919 7
|
||||
1920 9
|
||||
1921 6
|
||||
1922 11
|
||||
1924 7
|
||||
..
|
||||
|
||||
Total number of months: 201
|
||||
1900,1906,1917,1923,1928,1934,1945,1951,1956,1962,1973,1979,1984,1990,2001,2007,2012,2018,2029,2035,2040,2046,2057,2063,2068,2074,2085,2091,2096
|
||||
|
||||
Years with no five-weekend months: 29
|
||||
Loading…
Add table
Add a link
Reference in a new issue