diff --git a/src/Julia/Problem019.jl b/src/Julia/Problem019.jl new file mode 100644 index 0000000..a9b9955 --- /dev/null +++ b/src/Julia/Problem019.jl @@ -0,0 +1,45 @@ +#= +Created on 02 Aug 2021 + +@author: David Doblas Jiménez +@email: daviddoji@pm.me + +Solution for Problem 19 of Project Euler +https://projecteuler.net/problem=19 =# + +using Dates + +function Problem19() + """ + You are given the following information, but you may prefer to do some + research for yourself. + + 1 Jan 1900 was a Monday. + Thirty days has September, April, June and November. + All the rest have thirty-one, + Saving February alone, + Which has twenty-eight, rain or shine. + And on leap years, twenty-nine. + A leap year occurs on any year evenly divisible by 4, but not on a century + unless it is divisible by 400. + + How many Sundays fell on the first of the month during the twentieth + century (1 Jan 1901 to 31 Dec 2000)? + """ + sundays = 0 + for y in 1901:2000 + for m in 1:12 + # t = Date(y, m, 1) + if Dates.dayofweek(Date(y, m, 1)) == Dates.Sunday + sundays += 1 + end + end + end + return sundays +end + + +println("Time to evaluate Problem 19:") +@time Problem19() +println("") +println("Result for Problem 19: ", Problem19()) \ No newline at end of file