Article 2170 of rec.games.corewar: Newsgroups: rec.games.corewar Path: hellgate.utah.edu!dog.ee.lbl.gov!agate!howland.reston.ans.net!paladin.american.edu!darwin.sura.net!news.Vanderbilt.Edu!vuse.vanderbilt.edu!stst From: stst@vuse.vanderbilt.edu (Stefan Strack) Subject: Re: Michael's New Corewar Tournament: Round 1 Rules Message-ID: Sender: news@vuse.vanderbilt.edu Nntp-Posting-Host: necs Organization: Vanderbilt University School of Engineering, Nashville, TN, USA References: <2afdbc$108@agate.berkeley.edu> <2ah6qv$d7q@agate.berkeley.edu> Date: Mon, 25 Oct 1993 22:00:19 GMT Lines: 38 In article <2ah6qv$d7q@agate.berkeley.edu> mconst@OCF.Berkeley.EDU (Michael Constant) writes: > There will also be a >'miscellaneous' problem which I think will be computing prime numbers. I >know it can be done but I have to write one myself to see how long it should >be allowed to be (I don't think 100 will be enough). >-- > - Michael Constant Too easy, try 13 instructions :-) -Stefan (stst@vuse.vanderbilt.edu) ;redcode ;name Sieve of Aristostenes (sp?) ;author Stefan Strack ;strategy calculate prime numbers until LIMIT; non-prime numbers in array ;strategy are set to -1. Not efficient since upper bound (label 'bound') ;strategy is not recalculated. LIMIT equ 100 fill mov addptr,@addptr ; fill array with potential primes sub #1,addptr djn fill,#LIMIT loop add priptr,addptr ; weed out all multiples of priptr jmz next,@addptr mov #-1,@addptr ; indicate a non-prime jmp loop next add #1,priptr ; increment priptr and check if done mov priptr,addptr bound slt #LIMIT,priptr ; this is inefficient, since bound := bound / priptr jmp loop priptr dat #2 addptr dat #LIMIT end fill