13日の金曜日を数える
30分プログラム、その449。http://gauc.no-ip.org/awk-users-jp/blis.cgi/DoukakuAWK_047より。元ネタはエロと風俗情報満載 どう抜く?らしい。
使い方
;; 2008年には1回だけ gosh> (count-13-friday 2008) 1 ;; 2009年は3回ある gosh> (count-13-friday 2009) 3
ソースコード
#! /opt/local/bin/gosh ;; -*- mode:scheme; coding:utf-8 -*- ;; ;; 13fri.scm - ;; ;; Copyright(C) 2008 by mzp ;; Author: MIZUNO Hiroki / mzpppp at gmail dot com ;; http://howdyworld.org ;; ;; Timestamp: 2008/12/30 23:17:25 ;; ;; This program is free software; you can redistribute it and/or ;; modify it under MIT Lincence. ;; (use srfi-1) (use srfi-19) (define (make year month) (make-date 0 0 0 0 13 month year 0)) (define (friday? date) (= 5 (date-week-day date))) (define (count-13-friday year) (length (filter friday? (map (cut make year <>) (iota 12 1)))))