From: Paul Robinson Date: 2006-09-29T21:41:28+09:00 Subject: Re: [ANN] Code Golf Challenge : Oblongular Number Spirals On 28 Sep 2006, at 23:03, Sander Land wrote: > f=proc{|n,m,k,o|n*m<1?[]:k>0?f[n-1,m-=1,m-k,n+m+o].reverse< [*o...n+o]} > x,y=gets(" ").to_i,gets.to_i > y.times{|i|puts f[x,y,i,1].map{|t|"%3s"%t}*" "} > > Few bytes off the first line, but the largest gain is from the last > line :) > And yes this works, although it needed 2 tries to pass. 2 tries to pass? It doesn't work for all cases then! Cheat! :-) My solution works for all cases but it a bloated 428 bytes when the linewraps are gone. It's on my blog here: http://vagueware.com/2006/9/29/code-golf > Also, this was my 63 byte solution to the pi problem, in case anybody > is interested. > a=b=10**1000;4000.downto(1){|k|a=a*k/(2*k+1)+2*b};print"3.",a%b Hmmmm. I think I can see a way of getting a few bytes off that. Thanks for the starter. :-) > btw: what's up with the ultra-small PHP solutions? pi in 34 bytes and > this one in 113? Is there some network/filesystem call going on there? You can't 'include' anything, but PHP comes bundled with a huge standard API compared to the standard Ruby stack. This makes it bloated and horrible to work with (especially as how you call it and what you get back is inconsistent across the whole thing), but it does mean they can do some interesting things when playing Code Golf. It's been ages since I did any PHP, but I can immediately think how to do your pi solution in less bytes in PHP, and I think there's a way of using the API to do it in even less than that. As it is, I'm Golfing to improve my Ruby kung-fu, not to win, so I'm happy with my bloated solutions that are elegant in their own way. :-) -- Paul