Days in indexed month
APL (Dyalog Unicode), 13 12 bytesSBCS



Anonymous tacit prefix function. 0-indexed. February is 29.

31-1∘=+2|7∘|


Try it online!

31- thirty-one minus…

 1∘= the equal-to-one'ness…

  + plus…

   2| the two-mod of…

    7∘| the seven-mod'ness


  The reason I ask this near-duplicate is curiosity about mathematical patterns in the sequence of numbers. For example, a simple observation is that even-indexed months have 31 until August and then it flips — but golf that observation and/or make better ones that yield better strokes...


This solution implements the following mathematical pattern:

$$f(x)=31-[x=1]-\big((x\mod 7)\mod 2\big)$$

or

$$f(x)=31-x-\left[x=1\right]+7\left\lfloor\frac{x}7\right\rfloor+2\left\lfloor x-7\left\lfloor\frac{x}7\right\rfloor\over2\right\rfloor$$