[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Only one Friday 13th coming in 2016
From: |
Bill Duncan |
Subject: |
Re: Only one Friday 13th coming in 2016 |
Date: |
Wed, 23 Dec 2015 11:11:27 -0500 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
Dang! I love this list.
Looks like I haven't done a "man cal" for many years. I didn't know
about "ncal".. lol.
I remember there was a note in the old Version 7 manuals about reading
the man pages periodically..
Thanks Ken!
On Tue, Dec 22, 2015 at 10:59:18AM -0900, Ken Irving wrote:
> On Tue, Dec 22, 2015 at 04:04:16AM +0100, ?ngel Gonz?lez wrote:
> > Bill Duncan wrote:
> > > Remember that while there are 14 patterns of years, leap years don't
> > > impact Friday the 13th for January/February..
> > >
> > > This isn't an exhaustive analysis, but a quick check for 300 years
> > > didn't show any years without a Friday 13th..
> > >
> > > ;-)
> > >
> > > $ for y in {1900..2199} ; do for m in {1..12};do cal $m $y|awk
> > > 'FNR==1{m=$0}/^ 1/{print m}';done;done | awk '{y[$2]++} END {for
> > > (i=1900;i<2200;i++) if (!(i in y)) print i}'
> > > $
> >
> >
> > Aren't you making things more complex than needed, with so much pipes
> > and awk?
> >
> > date(1) is your friend:
> >
> > For instance:
> > ?$ for y in {1900..2199} ; do echo -n "$y "; for m in {1..12}; do date +%A
> > -d $y-$m-13; done | grep -c Friday ; done
> >
> > shows there are between 1 and 3 Fridays per year.
> >
> >
> > Or a mere listing:
> > $?for y in {1900..2199} ; do for m in {1..12}; do date +%A -d $y-$m-13;
> > done; done | sort | uniq -c | sort -rn
> >
> > That the most common weekday in these three centuries for the 13th is???
> > you guessed it, Friday.
>
> Can't resist... cal(1)'s ncal option/version puts all Fridays on a line, so...
>
> $ for y in {1900..2199}; do ncal $y | grep ^Fr | tr \ \\n |
> grep 13 | wc -l; done | sort | uniq -c
> 128 1
> 128 2
> 44 3
>
> and using the full range of cal(1) years:
>
> $ time for y in {1..9999}; do ncal $y | grep ^Fr | tr \ \\n |
> grep 13 | wc -l; done | sort | uniq -c
> 4274 1
> 4258 2
> 1467 3
>
> real 0m52.301s
> user 0m33.116s
> sys 0m11.816s
>
> and one more pass to count 'Friday the 13th' per month, but I guess
> there can only be 0 or 1 anyway, so probably not very interesting:
>
> $ time for m in {1..12}; do echo m=$m; for ((y=1; y<9999+1; y+=1)); \
> do ncal $m $y| grep ^Fr | tr \ \\n | grep 13 | wc -l; done |
> sort | uniq -c; done
> m=1
> 8552 0
> 1447 1
> m=2
> 8574 0
> 1425 1
> m=3
> 8552 0
> 1447 1
> ...
> m=11
> 8553 0
> 1446 1
> m=12
> 8573 0
> 1426 1
>
> real 10m25.149s
> user 6m57.916s
> sys 2m4.284s
>
> I cheated and edited and filtered the above output to show counts by
> month:
>
> 1403 8
> 1405 10
> 1425 2
> 1425 6
> 1426 12
> 1426 9
> 1446 11
> 1447 1
> 1447 3
> 1447 4
> 1447 5
> 1447 7
>
> For some reason August and October have the fewest Friday the 13th's.
>
>
--
Bill Duncan,
bduncan@beachnet.org
+1 416 697-9315