Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #12121

Re: Only one Friday 13th coming in 2016

Path csiph.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!news.glorb.com!usenet.stanford.edu!not-for-mail
From Bill Duncan <bduncan@beachnet.org>
Newsgroups gnu.bash.bug
Subject Re: Only one Friday 13th coming in 2016
Date Wed, 23 Dec 2015 11:11:27 -0500
Lines 116
Approved bug-bash@gnu.org
Message-ID <mailman.461.1450887101.843.bug-bash@gnu.org> (permalink)
References <slrnn7g4tl.2r3t.knock_yourself_out@vps.jonz.net> <20151221151338.GW27325@eeg.ccf.org> <20151222010544.GA21298@linda> <1450753456.7845.5.camel@16bits.net> <20151222195918.GA28185@localhost>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
X-Trace usenet.stanford.edu 1450887102 27907 208.118.235.17 (23 Dec 2015 16:11:42 GMT)
X-Complaints-To action@cs.stanford.edu
Cc bug-bash@gnu.org, ?ngel Gonz?lez <angel@16bits.net>
To Ken Irving <ken.irving@alaska.edu>
Envelope-to bug-bash@gnu.org
Content-Disposition inline
In-Reply-To <20151222195918.GA28185@localhost>
User-Agent Mutt/1.5.21 (2010-09-15)
X-SA-Exim-Connect-IP <locally generated>
X-SA-Exim-Rcpt-To ken.irving@alaska.edu, angel@16bits.net, bug-bash@gnu.org
X-SA-Exim-Mail-From bduncan@beachnet.org
X-SA-Exim-Scanned No (on linda.beachnet.org); SAEximRunCond expanded to false
X-detected-operating-system by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From 69.28.195.242
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.14
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <http://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
Xref csiph.com gnu.bash.bug:12121

Show key headers only | View raw


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

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: Only one Friday 13th coming in 2016 Bill Duncan <bduncan@beachnet.org> - 2015-12-23 11:11 -0500

csiph-web