Path: utzoo!mnetor!uunet!husc6!mailrus!tut.cis.ohio-state.edu!bloom-beacon!gatech!purdue!decwrl!labrea!polya!rokicki From: rokicki@polya.STANFORD.EDU (Tomas G. Rokicki) Newsgroups: comp.sys.amiga.tech Subject: Re: Idea Message-ID: <2699@polya.STANFORD.EDU> Date: 27 Apr 88 18:25:00 GMT References: <8804231647.AA09390@jade.berkeley.edu> <5809@well.UUCP> <9289@agate.BERKELEY.EDU> Reply-To: rokicki@polya.UUCP (Tomas G. Rokicki) Organization: Stanford University Lines: 29 > Speaking of kludges regarding the date, sorry for the miniflame, but: > both Peck (the book's author) and Rokicki (who wrote this particular piece > of code) should be *ashamed* to have released a piece of code like > ShowDate() on page 42 of the Programmer's Guide to the Amiga. I thought > it was a publisher's misprint at first, it was so full of magic meaningless > constants. Naw, ShowDate() is actually pretty neat! (Of course, I wrote it.) It was *intended* (by me at least) to be a magic piece of code; the puzzle was to figure out how it worked. Ditto with my blitter LIFE. Anyone could and can write the straight-forward approach; I wanted an approach which would use the mininum number of bytes and execute in the quickest time. Not for any real purpose (except to save a couple of bytes) but simply as a puzzle. > The algorithm is *totally* opaque, despite the fact that I understand > the USUAL approaches to date algorithms, including the the one for > calculating the day of the week that any day in history falls on, in your > head. So I tried to prove it didn't work. Well, I was wrong, it does work > (as far as I could tell). I even started to get an idea of why before I > gave it up as a waste of time. The algorithm in ShowDate() is very close to the one for calculating the day of the week that any day in history falls on. I'm sorry you had such difficulties figuring it out; maybe I'll explain it to you at DevCon. Programming wouldn't be half as fun if I couldn't come up with gems like that.