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
New contributor
$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
New contributor
$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
18 hours ago
$begingroup$
Wolfram Challenges.
$endgroup$
– J. M. is computer-less♦
11 hours ago
$begingroup$
Sounds like one for the code golf boys and girls
$endgroup$
– Strawberry
1 hour ago
$begingroup$
Oh, of course they did it already: codegolf.stackexchange.com/questions/69510/…
$endgroup$
– Strawberry
1 hour ago
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
New contributor
$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
New contributor
New contributor
edited 11 hours ago
J. M. is computer-less♦
97.1k10303463
97.1k10303463
New contributor
asked 18 hours ago
BradPeterson87BradPeterson87
433
433
New contributor
New contributor
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
18 hours ago
$begingroup$
Wolfram Challenges.
$endgroup$
– J. M. is computer-less♦
11 hours ago
$begingroup$
Sounds like one for the code golf boys and girls
$endgroup$
– Strawberry
1 hour ago
$begingroup$
Oh, of course they did it already: codegolf.stackexchange.com/questions/69510/…
$endgroup$
– Strawberry
1 hour ago
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
18 hours ago
$begingroup$
Wolfram Challenges.
$endgroup$
– J. M. is computer-less♦
11 hours ago
$begingroup$
Sounds like one for the code golf boys and girls
$endgroup$
– Strawberry
1 hour ago
$begingroup$
Oh, of course they did it already: codegolf.stackexchange.com/questions/69510/…
$endgroup$
– Strawberry
1 hour ago
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
18 hours ago
$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
18 hours ago
$begingroup$
Wolfram Challenges.
$endgroup$
– J. M. is computer-less♦
11 hours ago
$begingroup$
Wolfram Challenges.
$endgroup$
– J. M. is computer-less♦
11 hours ago
$begingroup$
Sounds like one for the code golf boys and girls
$endgroup$
– Strawberry
1 hour ago
$begingroup$
Sounds like one for the code golf boys and girls
$endgroup$
– Strawberry
1 hour ago
$begingroup$
Oh, of course they did it already: codegolf.stackexchange.com/questions/69510/…
$endgroup$
– Strawberry
1 hour ago
$begingroup$
Oh, of course they did it already: codegolf.stackexchange.com/questions/69510/…
$endgroup$
– Strawberry
1 hour ago
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
});
}
});
BradPeterson87 is a new contributor. Be nice, and check out our Code of Conduct.
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 18 hours ago
Kuba♦Kuba
106k12205527
106k12205527
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 18 hours ago
m_goldbergm_goldberg
87.2k872198
87.2k872198
add a comment |
add a comment |
BradPeterson87 is a new contributor. Be nice, and check out our Code of Conduct.
BradPeterson87 is a new contributor. Be nice, and check out our Code of Conduct.
BradPeterson87 is a new contributor. Be nice, and check out our Code of Conduct.
BradPeterson87 is a new contributor. Be nice, and check out our Code of Conduct.
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
18 hours ago
$begingroup$
Wolfram Challenges.
$endgroup$
– J. M. is computer-less♦
11 hours ago
$begingroup$
Sounds like one for the code golf boys and girls
$endgroup$
– Strawberry
1 hour ago
$begingroup$
Oh, of course they did it already: codegolf.stackexchange.com/questions/69510/…
$endgroup$
– Strawberry
1 hour ago