How to count occurrences of Friday 13th












6












$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










share|improve this question









New contributor




BradPeterson87 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$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
    10 hours ago










  • $begingroup$
    Wolfram Challenges.
    $endgroup$
    – J. M. is computer-less
    4 hours ago
















6












$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










share|improve this question









New contributor




BradPeterson87 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$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
    10 hours ago










  • $begingroup$
    Wolfram Challenges.
    $endgroup$
    – J. M. is computer-less
    4 hours ago














6












6








6





$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










share|improve this question









New contributor




BradPeterson87 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$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






share|improve this question









New contributor




BradPeterson87 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




BradPeterson87 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 4 hours ago









J. M. is computer-less

97.1k10303463




97.1k10303463






New contributor




BradPeterson87 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 11 hours ago









BradPeterson87BradPeterson87

333




333




New contributor




BradPeterson87 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





BradPeterson87 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






BradPeterson87 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 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
    10 hours ago










  • $begingroup$
    Wolfram Challenges.
    $endgroup$
    – J. M. is computer-less
    4 hours ago














  • 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
    10 hours ago










  • $begingroup$
    Wolfram Challenges.
    $endgroup$
    – J. M. is computer-less
    4 hours 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
10 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
10 hours ago












$begingroup$
Wolfram Challenges.
$endgroup$
– J. M. is computer-less
4 hours ago




$begingroup$
Wolfram Challenges.
$endgroup$
– J. M. is computer-less
4 hours ago










2 Answers
2






active

oldest

votes


















7












$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" &
]





share|improve this answer









$endgroup$





















    9












    $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


    2014



    friday13th @ 2015


    2015



    And for this year, I get



    friday13th @ 2019


    2019






    share|improve this answer









    $endgroup$













      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.










      draft saved

      draft discarded


















      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









      7












      $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" &
      ]





      share|improve this answer









      $endgroup$


















        7












        $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" &
        ]





        share|improve this answer









        $endgroup$
















          7












          7








          7





          $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" &
          ]





          share|improve this answer









          $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" &
          ]






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 10 hours ago









          KubaKuba

          106k12205527




          106k12205527























              9












              $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


              2014



              friday13th @ 2015


              2015



              And for this year, I get



              friday13th @ 2019


              2019






              share|improve this answer









              $endgroup$


















                9












                $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


                2014



                friday13th @ 2015


                2015



                And for this year, I get



                friday13th @ 2019


                2019






                share|improve this answer









                $endgroup$
















                  9












                  9








                  9





                  $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


                  2014



                  friday13th @ 2015


                  2015



                  And for this year, I get



                  friday13th @ 2019


                  2019






                  share|improve this answer









                  $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


                  2014



                  friday13th @ 2015


                  2015



                  And for this year, I get



                  friday13th @ 2019


                  2019







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 10 hours ago









                  m_goldbergm_goldberg

                  87.2k872197




                  87.2k872197






















                      BradPeterson87 is a new contributor. Be nice, and check out our Code of Conduct.










                      draft saved

                      draft discarded


















                      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.




                      draft saved


                      draft discarded














                      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





















































                      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







                      Popular posts from this blog

                      GameSpot

                      日野市

                      Tu-95轟炸機