From: David Balmain Date: 2005-11-21T14:30:34+09:00 Subject: Re: [QUIZ SOLUTION] Euchre Hands (#55) Ryan, how about changing /(J#{u})|(J#{v})/ to /J[#{u}#{v}]/? That'll save you a couple more characters. :p On 11/21/05, Ryan Leavengood wrote: > Thanks to inspiration from reading Zed Lopez's code, I've been able to > cut my golfed solution from 242 bytes to 214. Unfortunately for you > Zed, this now means your is now 108 bytes longer :) > > The fixes were: > > 1. Using s[x,1] instead of s[x..x] to get a single character from a > string. This saved 2 bytes. > 2. Calculating the weights INSIDE the sort_by, instead of using a > separate hash. This seems so obvious now I slapped my head when I saw > Zed's code doing this. This saved a whopping 26 bytes. > > So, if anyone is interested: > > a=$<.read.split("\n");s=%w{d c h > s};c='AKQJT9';t=a.shift;u=(t[0]+32).chr;i=s.index(u);v=s[(i+2)%4];w=[1];i.upto(i+3){|j|w< t,a.sort_by{|k|k=~/(J#{u})|(J#{v})/?$1?0:1:w.index(k[1,1])*10+c.index(k[0,1])} > > I will be highly impressed if someone can go shorter than this. Also > if anyone wants it I can post a message "decoding" the above. > > Ryan > >