-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7addbda
commit 0b679b8
Showing
6 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Fortran Implementation of Problem 19 | ||
==================================== | ||
|
||
View source code :source:`fortran/src/p0019.f90` | ||
|
||
.. f:module:: Problem0019 | ||
.. f:function:: integer Problem0019/p0019() | ||
.. literalinclude:: ../../../fortran/src/p0019.f90 | ||
:language: Fortran | ||
:linenos: | ||
|
||
.. tags:: calendar, combinatorics |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
-- Project Euler Problem 19 | ||
-- | ||
-- This one ended up being very easy thanks to the time library | ||
-- | ||
-- Problem: | ||
-- | ||
-- 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)? | ||
|
||
local function is_sunday(year, month, day) | ||
return os.date("*t", os.time({year=year, month=month, day=day})).wday == 1 | ||
end | ||
|
||
return { | ||
solution = function() | ||
local answer = 0 | ||
for year = 1901, 2000 do | ||
for month = 1, 12 do | ||
if is_sunday(year, month, 1) then | ||
answer = answer + 1 | ||
end | ||
end | ||
end | ||
return answer | ||
end | ||
} |
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