Time for an 2014 update…
This commit is contained in:
parent
372c577f83
commit
09687c4926
2520 changed files with 34227 additions and 7318 deletions
17
Task/Five-weekends/Groovy/five-weekends-1.groovy
Normal file
17
Task/Five-weekends/Groovy/five-weekends-1.groovy
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
enum Day {
|
||||
Sun, Mon, Tue, Wed, Thu, Fri, Sat
|
||||
static Day valueOf(Date d) { Day.valueOf(d.format('EEE')) }
|
||||
}
|
||||
|
||||
def date = Date.&parse.curry('yyyy-M-dd')
|
||||
def isLongMonth = { firstDay -> (firstDay + 31).format('dd') == '01'}
|
||||
|
||||
def fiveWeekends = { years ->
|
||||
years.collect { year ->
|
||||
(1..12).collect { month ->
|
||||
date("${year}-${month}-01")
|
||||
}.findAll { firstDay ->
|
||||
isLongMonth(firstDay) && Day.valueOf(firstDay) == Day.Fri
|
||||
}
|
||||
}.flatten()
|
||||
}
|
||||
5
Task/Five-weekends/Groovy/five-weekends-2.groovy
Normal file
5
Task/Five-weekends/Groovy/five-weekends-2.groovy
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
def ym = { it.format('yyyy-MM') }
|
||||
def years = 1900..2100
|
||||
def fiveWeekendMonths = fiveWeekends(years)
|
||||
println "Number of five weekend months: ${fiveWeekendMonths.size()}"
|
||||
fiveWeekendMonths.each { println (ym(it)) }
|
||||
4
Task/Five-weekends/Groovy/five-weekends-3.groovy
Normal file
4
Task/Five-weekends/Groovy/five-weekends-3.groovy
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
def yearsWith = fiveWeekendMonths.collect { it.format('yyyy') as int } as Set
|
||||
def yearsWithout = (years as Set) - yearsWith
|
||||
println "\nNumber of years without a five weekend month: ${yearsWithout.size()}"
|
||||
yearsWithout.each { println it }
|
||||
11
Task/Five-weekends/VBScript/five-weekends.vb
Normal file
11
Task/Five-weekends/VBScript/five-weekends.vb
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
For y = 1900 To 2100
|
||||
For m = 1 To 12
|
||||
d = DateSerial(y, m + 1, 1) - 1
|
||||
If Day(d) = 31 And Weekday(d) = vbSunday Then
|
||||
WScript.Echo y & ", " & MonthName(m)
|
||||
i = i + 1
|
||||
End If
|
||||
Next
|
||||
Next
|
||||
|
||||
WScript.Echo vbCrLf & "Total = " & i & " months"
|
||||
Loading…
Add table
Add a link
Reference in a new issue