IMO a trivial condition in performance competitions is that the measured time and space contain all calculations needed for the desired result and eventually can be reproduced in a new session in a freshly installed J-version.
I should have mentioned more prominently (not only between parentheses) that y is (supposed to be) an array of natural numbers. As Groenevelt pointed out, where I wrote 5 ts&'... I meant 5 ts &>'.... R.E. Boss > -----Oorspronkelijk bericht----- > Van: [EMAIL PROTECTED] [mailto:programming- > [EMAIL PROTECTED] Namens Roger Hui > Verzonden: woensdag 2 januari 2008 20:52 > Aan: Programming forum > Onderwerp: Re: [Jprogramming] FW: (New Year) Competition: most > efficientalternative for ([: *./ >:@i.)"0 y for extended y > > You may wish to tighten the conditions on the competition, > for example to exclude the following: > > L=: *./@:>:@:i."0 i.1000x > f2=: {&L > f2 99 > 69720375229712477164533808935312303556800 > > y=: 100 [EMAIL PROTECTED] 1000x > ts 'f2 y' > 5.11238e_5 2112 > > By the way: > > lcm 0x > |index error > | y ((([EMAIL PROTECTED]){.){{:@])z2 > > > > ----- Original Message ----- > From: "R.E. Boss" <[EMAIL PROTECTED]> > Date: Monday, December 31, 2007 11:55 > Subject: [Jprogramming] FW: (New Year) Competition: most efficient > alternative for ([: *./ >:@i.)"0 y for extended y > To: 'Programming forum' <[email protected]> > > > > > > > 5 ts '([:*./ >:@i.)"0 y'[y=:[EMAIL PROTECTED] 1000x > > 0.28845623 188992 > > > > is not an optimal solution, see > > > > 5 ts '([:*./&.|. >:@i.)"0 y' > > 0.20137625 189504 > > > > (([:*./ >:@i.)"0 -: ([:*./&.|. >:@i.)"0) y > > 1 > > > > Nevertheless, the first ([:*./ >:@i.)"0 will serve as the > > benchmark.(You may use any y (of natural numbers) you like.) > > > > Solutions foo0, foo1, ... will be ranked according to > > > > (\:,.]) 2 rsd ({.%"1 ]) 5 ts&'([:*./ >:@i.)"0 y';'foo0 y';'foo1 > > y';'....' > > with > > > > ts=: 6!:2 , 7!:[EMAIL PROTECTED] > > > > and with > > > > rsd=: 4 : 0 NB. > > round y to x significant digits > > z0=. (<: x) + -@<.@(10&^.)y > > z1=. 0.5<[EMAIL PROTECTED] y (*10&^) z0 > > (10^- z0)* z1 > > ) > > > > Of course one should have > > (fooX -: ([:*./ >:@i.)"0) y > > 1 > > > > (Perhaps, under http://www.jsoftware.com/jwiki/Showcase there > > should be a > > subpage Competitions.) > > > > > > Here is my try: > > > > y=:[EMAIL PROTECTED] 1000x > > (\:,.]) 2 rsd ({.%"1 ]) 5 ts&'([:*./ >:@i.)"0 > > y';'([:*./&.|. >:@i.)"0 > > y';'lcm y' NB. wrap around! > > 2 1 1 > > 1 1.3 1 > > 0 90 0.45 > > (lcm -: ([:*./ >:@i.)"0) y > > 1 > > > > y=:[EMAIL PROTECTED] 10000x > > (\:,.]) 2 rsd ({.%"1 ]) 5 ts&'([:*./ >:@i.)"0 > > y';'([:*./&.|. >:@i.)"0 > > y';'lcm y' NB. wrap around! > > 2 1 1 > > 1 1.6 1 > > 0 280 0.11 > > (lcm -: ([:*./ >:@i.)"0) y > > 1 > > > > lcm is defined by > > > > lcm=: 3 : 0 > > z0=. i.&.(_1&p:)1x+m=: >./, y > > NB. primes less than max y > > z1=. |:/:~;(<@([,.~ (^ >:@i.@>:))"0 <.@:^.&m) z0 > > NB. prime powers with corresponding primes > > z2=. ({.,: [:*/\.&.|. {:) z1 > > NB. prime powers with corresponding ([:*./ >:@i.) > > y(((I.~- [EMAIL PROTECTED]){.){ {:@]) z2 > > NB. ([:*./ >:@i.)"0 y > > ) > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
