Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 beta 3/9/83; site sdcrdcf.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxl!ihnp4!zehntel!hplabs!sdcrdcf!pmontgom From: pmontgom@sdcrdcf.UUCP (Peter Montgomery) Newsgroups: net.lang.f77,net.puzzle Subject: A Shorter Calendar Printing Program Message-ID: <906@sdcrdcf.UUCP> Date: Sun, 11-Mar-84 18:51:25 EST Article-I.D.: sdcrdcf.906 Posted: Sun Mar 11 18:51:25 1984 Date-Received: Tue, 13-Mar-84 07:52:25 EST Reply-To: pmontgom@sdcrdcf.UUCP (Peter Montgomery) Organization: System Development Corporation, Santa Monica Lines: 24 In "The Strange Power of FORTRAN: A Very Short Calendar Printing Program", ACM SIMSOFT Software Engineering Notes, Volume 9, No. 1, January, 1984, pp. 50-51, Hans Janssens presents a 19-line FORTRAN program for reading a year and printing its calendar. Here is a 10-line program. The program can be shortened to 9 lines by renaming its integer variables as I, J, K, L, M, N and removing the INTEGER statement. I believe the program complies with the 1977 standard (full language). I leave it to you to decipher it. CHARACTER DY*7, H(-10:1)*14 INTEGER D, M, Q, S, W, Y S(M)=5*(Y+M/9)/4-(Y+M/9)/100+(Y+M/9)/400 + (153*M+1516-16*(M/9))/5 DATA H,DY/'JANUARY','FEBRUARY','MARCH','APRIL','MAY','JUNE','JULY' *,'AUGUST','SEPTEMBER','OCTOBER','NOVEMBER','DECEMBER','MTWTFSS'/ READ *, Y PRINT'(1H1///4X,17HCOMPUTER CALENDAR,I5////4(//3(I8,A16)//7(3(A5, *1X,6I3.0)/)),1H1)',Y,((Y,H(M),M=Q-2,Q),((DY(D:D),(DIM (MOD(D+7*W- *MOD(S(M),7),15+S(M+1)-S(M)), 14),W=2,7),M=Q-2,Q),D=1,7),Q=-8,1,3) END -- Peter Montgomery {bli,blix,bmcg,burdvax,cbosgd,csun,hplabs,hughes,ihnp4,ihnss, netvax,orstcs,parallax,randvax,sdccsu3,sdcnet,sdcsvax,slant45, trw-unix,ucla-s,ucla-vax}!sdcrdcf!pmontgom