How to count occurrences of Friday 13th
$begingroup$
I would like to find a function that will count the number of times Friday 13th happens in a particular calendar year.
Does anybody have any hints ?
Thank you
date-and-time
$endgroup$
add a comment |
$begingroup$
I would like to find a function that will count the number of times Friday 13th happens in a particular calendar year.
Does anybody have any hints ?
Thank you
date-and-time
$endgroup$
1
$begingroup$
I fell into a delightful rabbit hole of day-counting algorithms on Wikipedia. I wanted to leave a link to the Doomsday algorithm for mental calculation of the day of the week, for fun: Doomsday rule on Wiki.
$endgroup$
– MarcoB
Mar 4 at 19:54
$begingroup$
Wolfram Challenges.
$endgroup$
– J. M. is slightly pensive♦
Mar 5 at 2:21
$begingroup$
Sounds like one for the code golf boys and girls
$endgroup$
– Strawberry
Mar 5 at 13:05
$begingroup$
Oh, of course they did it already: codegolf.stackexchange.com/questions/69510/…
$endgroup$
– Strawberry
Mar 5 at 13:11
add a comment |
$begingroup$
I would like to find a function that will count the number of times Friday 13th happens in a particular calendar year.
Does anybody have any hints ?
Thank you
date-and-time
$endgroup$
I would like to find a function that will count the number of times Friday 13th happens in a particular calendar year.
Does anybody have any hints ?
Thank you
date-and-time
date-and-time
edited Mar 5 at 2:20
J. M. is slightly pensive♦
97.8k10304464
97.8k10304464
asked Mar 4 at 19:23
user63250
1
$begingroup$
I fell into a delightful rabbit hole of day-counting algorithms on Wikipedia. I wanted to leave a link to the Doomsday algorithm for mental calculation of the day of the week, for fun: Doomsday rule on Wiki.
$endgroup$
– MarcoB
Mar 4 at 19:54
$begingroup$
Wolfram Challenges.
$endgroup$
– J. M. is slightly pensive♦
Mar 5 at 2:21
$begingroup$
Sounds like one for the code golf boys and girls
$endgroup$
– Strawberry
Mar 5 at 13:05
$begingroup$
Oh, of course they did it already: codegolf.stackexchange.com/questions/69510/…
$endgroup$
– Strawberry
Mar 5 at 13:11
add a comment |
1
$begingroup$
I fell into a delightful rabbit hole of day-counting algorithms on Wikipedia. I wanted to leave a link to the Doomsday algorithm for mental calculation of the day of the week, for fun: Doomsday rule on Wiki.
$endgroup$
– MarcoB
Mar 4 at 19:54
$begingroup$
Wolfram Challenges.
$endgroup$
– J. M. is slightly pensive♦
Mar 5 at 2:21
$begingroup$
Sounds like one for the code golf boys and girls
$endgroup$
– Strawberry
Mar 5 at 13:05
$begingroup$
Oh, of course they did it already: codegolf.stackexchange.com/questions/69510/…
$endgroup$
– Strawberry
Mar 5 at 13:11
1
1
$begingroup$
I fell into a delightful rabbit hole of day-counting algorithms on Wikipedia. I wanted to leave a link to the Doomsday algorithm for mental calculation of the day of the week, for fun: Doomsday rule on Wiki.
$endgroup$
– MarcoB
Mar 4 at 19:54
$begingroup$
I fell into a delightful rabbit hole of day-counting algorithms on Wikipedia. I wanted to leave a link to the Doomsday algorithm for mental calculation of the day of the week, for fun: Doomsday rule on Wiki.
$endgroup$
– MarcoB
Mar 4 at 19:54
$begingroup$
Wolfram Challenges.
$endgroup$
– J. M. is slightly pensive♦
Mar 5 at 2:21
$begingroup$
Wolfram Challenges.
$endgroup$
– J. M. is slightly pensive♦
Mar 5 at 2:21
$begingroup$
Sounds like one for the code golf boys and girls
$endgroup$
– Strawberry
Mar 5 at 13:05
$begingroup$
Sounds like one for the code golf boys and girls
$endgroup$
– Strawberry
Mar 5 at 13:05
$begingroup$
Oh, of course they did it already: codegolf.stackexchange.com/questions/69510/…
$endgroup$
– Strawberry
Mar 5 at 13:11
$begingroup$
Oh, of course they did it already: codegolf.stackexchange.com/questions/69510/…
$endgroup$
– Strawberry
Mar 5 at 13:11
add a comment |
2 Answers
2
active
oldest
votes
$begingroup$
Select[
Table[DateObject@{2019, m, 13}, {m, 12}],
DateString[#, "DayName"] === "Friday" &
]
{Day: Fri 13 Sep 2019,Day: Fri 13 Dec 2019}
countFri13[year_Integer]:=Length @ Select[
Table[DateObject@{year, m, 13}, {m, 12}],
DateString[#, "DayName"] === "Friday" &
]
$endgroup$
add a comment |
$begingroup$
I worked on this problem in 2015. Here is part on my notebook from that time.
A not so good algorithm.
friday13th[year_Integer] :=
Select[DayName[#] === Friday &] @
DateRange[DateObject[{year, 1, 13}], DateObject[{year, 12, 13}], {1, "Month"}]
A good algorithm.
friday13th[year_Integer] :=
Select[DayName[#] === Friday &] @ Table[DateObject[{year, i, 13}], {i, 12}]
A better algorithm.
friday13th[year_Integer] :=
Select[DayName[#] === Friday &] @ Array[DateObject[{year, #, 13}] &, 12]
Using the better algorithm, I got (at the time I created the notebook)
friday13th @ 2014
friday13th @ 2015
And for this year, I get
friday13th @ 2019
$endgroup$
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "387"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f192605%2fhow-to-count-occurrences-of-friday-13th%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
Select[
Table[DateObject@{2019, m, 13}, {m, 12}],
DateString[#, "DayName"] === "Friday" &
]
{Day: Fri 13 Sep 2019,Day: Fri 13 Dec 2019}
countFri13[year_Integer]:=Length @ Select[
Table[DateObject@{year, m, 13}, {m, 12}],
DateString[#, "DayName"] === "Friday" &
]
$endgroup$
add a comment |
$begingroup$
Select[
Table[DateObject@{2019, m, 13}, {m, 12}],
DateString[#, "DayName"] === "Friday" &
]
{Day: Fri 13 Sep 2019,Day: Fri 13 Dec 2019}
countFri13[year_Integer]:=Length @ Select[
Table[DateObject@{year, m, 13}, {m, 12}],
DateString[#, "DayName"] === "Friday" &
]
$endgroup$
add a comment |
$begingroup$
Select[
Table[DateObject@{2019, m, 13}, {m, 12}],
DateString[#, "DayName"] === "Friday" &
]
{Day: Fri 13 Sep 2019,Day: Fri 13 Dec 2019}
countFri13[year_Integer]:=Length @ Select[
Table[DateObject@{year, m, 13}, {m, 12}],
DateString[#, "DayName"] === "Friday" &
]
$endgroup$
Select[
Table[DateObject@{2019, m, 13}, {m, 12}],
DateString[#, "DayName"] === "Friday" &
]
{Day: Fri 13 Sep 2019,Day: Fri 13 Dec 2019}
countFri13[year_Integer]:=Length @ Select[
Table[DateObject@{year, m, 13}, {m, 12}],
DateString[#, "DayName"] === "Friday" &
]
answered Mar 4 at 19:35
Kuba♦Kuba
106k12207529
106k12207529
add a comment |
add a comment |
$begingroup$
I worked on this problem in 2015. Here is part on my notebook from that time.
A not so good algorithm.
friday13th[year_Integer] :=
Select[DayName[#] === Friday &] @
DateRange[DateObject[{year, 1, 13}], DateObject[{year, 12, 13}], {1, "Month"}]
A good algorithm.
friday13th[year_Integer] :=
Select[DayName[#] === Friday &] @ Table[DateObject[{year, i, 13}], {i, 12}]
A better algorithm.
friday13th[year_Integer] :=
Select[DayName[#] === Friday &] @ Array[DateObject[{year, #, 13}] &, 12]
Using the better algorithm, I got (at the time I created the notebook)
friday13th @ 2014
friday13th @ 2015
And for this year, I get
friday13th @ 2019
$endgroup$
add a comment |
$begingroup$
I worked on this problem in 2015. Here is part on my notebook from that time.
A not so good algorithm.
friday13th[year_Integer] :=
Select[DayName[#] === Friday &] @
DateRange[DateObject[{year, 1, 13}], DateObject[{year, 12, 13}], {1, "Month"}]
A good algorithm.
friday13th[year_Integer] :=
Select[DayName[#] === Friday &] @ Table[DateObject[{year, i, 13}], {i, 12}]
A better algorithm.
friday13th[year_Integer] :=
Select[DayName[#] === Friday &] @ Array[DateObject[{year, #, 13}] &, 12]
Using the better algorithm, I got (at the time I created the notebook)
friday13th @ 2014
friday13th @ 2015
And for this year, I get
friday13th @ 2019
$endgroup$
add a comment |
$begingroup$
I worked on this problem in 2015. Here is part on my notebook from that time.
A not so good algorithm.
friday13th[year_Integer] :=
Select[DayName[#] === Friday &] @
DateRange[DateObject[{year, 1, 13}], DateObject[{year, 12, 13}], {1, "Month"}]
A good algorithm.
friday13th[year_Integer] :=
Select[DayName[#] === Friday &] @ Table[DateObject[{year, i, 13}], {i, 12}]
A better algorithm.
friday13th[year_Integer] :=
Select[DayName[#] === Friday &] @ Array[DateObject[{year, #, 13}] &, 12]
Using the better algorithm, I got (at the time I created the notebook)
friday13th @ 2014
friday13th @ 2015
And for this year, I get
friday13th @ 2019
$endgroup$
I worked on this problem in 2015. Here is part on my notebook from that time.
A not so good algorithm.
friday13th[year_Integer] :=
Select[DayName[#] === Friday &] @
DateRange[DateObject[{year, 1, 13}], DateObject[{year, 12, 13}], {1, "Month"}]
A good algorithm.
friday13th[year_Integer] :=
Select[DayName[#] === Friday &] @ Table[DateObject[{year, i, 13}], {i, 12}]
A better algorithm.
friday13th[year_Integer] :=
Select[DayName[#] === Friday &] @ Array[DateObject[{year, #, 13}] &, 12]
Using the better algorithm, I got (at the time I created the notebook)
friday13th @ 2014
friday13th @ 2015
And for this year, I get
friday13th @ 2019
answered Mar 4 at 19:52
m_goldbergm_goldberg
87.4k872198
87.4k872198
add a comment |
add a comment |
Thanks for contributing an answer to Mathematica Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f192605%2fhow-to-count-occurrences-of-friday-13th%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
$begingroup$
I fell into a delightful rabbit hole of day-counting algorithms on Wikipedia. I wanted to leave a link to the Doomsday algorithm for mental calculation of the day of the week, for fun: Doomsday rule on Wiki.
$endgroup$
– MarcoB
Mar 4 at 19:54
$begingroup$
Wolfram Challenges.
$endgroup$
– J. M. is slightly pensive♦
Mar 5 at 2:21
$begingroup$
Sounds like one for the code golf boys and girls
$endgroup$
– Strawberry
Mar 5 at 13:05
$begingroup$
Oh, of course they did it already: codegolf.stackexchange.com/questions/69510/…
$endgroup$
– Strawberry
Mar 5 at 13:11