How to count occurrences of Friday 13thDetermining the week of a year from a given dateJewishNewYear date...

lead or lag function to get several values, not just the nth

Are small insurances worth it

Six real numbers so that product of any five is the sixth one

If a set is open, does that imply that it has no boundary points?

Can throughput exceed the bandwidth of a network

Graphing random points on the XY-plane

Impact on website analytics caused by accessibility issues

How do I deal with being jealous of my own players?

How can I handle a player who pre-plans arguments about my rulings on RAW?

Practical reasons to have both a large police force and bounty hunting network?

Reason why dimensional travelling would be restricted

Is there a frame of reference in which I was born before I was conceived?

When an experienced monk meditates how much does their mind wander?

In iTunes 12 on macOS, how can I reset the skip count of a song?

Called into a meeting and told we are being made redundant (laid off) and "not to share outside". Can I tell my partner?

What could trigger powerful quakes on icy world?

At what level can a party fight a mimic?

Is it possible to make a clamp function shorter than a ternary in JS?

What are the issues with an additional (limited) concentration slot instead of Bladesong?

Is there any relevance to Thor getting his hair cut other than comedic value?

When was drinking water recognized as crucial in marathon running?

Dredging in a fantasy setting

I encountered my boss during an on-site interview at another company. Should I bring it up when seeing him next time?

Rationale to prefer local variables over instance variables?



How to count occurrences of Friday 13th


Determining the week of a year from a given dateJewishNewYear date limitationHow to sum values in the list that belongs to same weekEasterSunday replacement in Mathematica 10Iterate over days of year to make a list/graphHow to LinearModelFit data like {{year,month,day,hour,minute,second,variable}}?Timing evaluation times dynamicallyAdd another holiday to the built-in holiday calendarHow to programmatically determine information about a DateObjectcompute a length excluding periodic segments













9












$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











$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
    yesterday










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










  • $begingroup$
    Sounds like one for the code golf boys and girls
    $endgroup$
    – Strawberry
    12 hours ago










  • $begingroup$
    Oh, of course they did it already: codegolf.stackexchange.com/questions/69510/…
    $endgroup$
    – Strawberry
    12 hours ago
















9












$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











$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
    yesterday










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










  • $begingroup$
    Sounds like one for the code golf boys and girls
    $endgroup$
    – Strawberry
    12 hours ago










  • $begingroup$
    Oh, of course they did it already: codegolf.stackexchange.com/questions/69510/…
    $endgroup$
    – Strawberry
    12 hours ago














9












9








9





$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











$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















share|improve this question













share|improve this question




share|improve this question








edited 22 hours ago









J. M. is computer-less

97.2k10303463




97.2k10303463










asked yesterday







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
    yesterday










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










  • $begingroup$
    Sounds like one for the code golf boys and girls
    $endgroup$
    – Strawberry
    12 hours ago










  • $begingroup$
    Oh, of course they did it already: codegolf.stackexchange.com/questions/69510/…
    $endgroup$
    – Strawberry
    12 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
    yesterday










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










  • $begingroup$
    Sounds like one for the code golf boys and girls
    $endgroup$
    – Strawberry
    12 hours ago










  • $begingroup$
    Oh, of course they did it already: codegolf.stackexchange.com/questions/69510/…
    $endgroup$
    – Strawberry
    12 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
yesterday




$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
yesterday












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




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












$begingroup$
Sounds like one for the code golf boys and girls
$endgroup$
– Strawberry
12 hours ago




$begingroup$
Sounds like one for the code golf boys and girls
$endgroup$
– Strawberry
12 hours ago












$begingroup$
Oh, of course they did it already: codegolf.stackexchange.com/questions/69510/…
$endgroup$
– Strawberry
12 hours ago




$begingroup$
Oh, of course they did it already: codegolf.stackexchange.com/questions/69510/…
$endgroup$
– Strawberry
12 hours ago










2 Answers
2






active

oldest

votes


















10












$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$





















    14












    $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
      });


      }
      });














      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









      10












      $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$


















        10












        $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$
















          10












          10








          10





          $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 yesterday









          KubaKuba

          106k12206529




          106k12206529























              14












              $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$


















                14












                $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$
















                  14












                  14








                  14





                  $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 yesterday









                  m_goldbergm_goldberg

                  87.3k872198




                  87.3k872198






























                      draft saved

                      draft discarded




















































                      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

                      El tren de la libertad Índice Antecedentes "Porque yo decido" Desarrollo de la...

                      Castillo d'Acher Características Menú de navegación

                      Connecting two nodes from the same mother node horizontallyTikZ: What EXACTLY does the the |- notation for...