From: Patrick Hurley Date: 2005-03-23T23:20:19+09:00 Subject: Re: [QUIZ SOLUTION] Texas Hold'Em (#24) (no lines over 72 chars in length :-) Thanks - I need to keep the low aces so that they appear in the correct position in the rearranged hand - if I had just deleted them, straights with the aces low would have been displayed with the ace out of order. I liked the delta transform as well, of course it was the cause of the bug (delta 0 when pairs were encountered) - if fixed it by shuffling the delta zeros (excluding the first card) to the back of the hand. Patrick On Wed, 23 Mar 2005 23:02:00 +0900, Carlos wrote: > [Patrick Hurley , 2005-03-23 03.39 CET] > > Find below a very slightly modified version of my quiz submission > [...] > > def fix_low_ace_display(arranged_hand) > > # remove card deltas (this routine is only used for straights) > > arranged_hand.gsub!(/\S(\S\S)\s+/, "\\1 ") > > > > # Fix "low aces" > > arranged_hand.gsub!(/L(\S)/, "A\\1") > > > > # Remove duplicate aces (this will not work if you have > > # multiple decks or wild cards) > > arranged_hand.gsub!(/((A\S).*)\2/, "\\1") > > Why not just delete the low aces (gsub!(/L./, ""))? What am I missing? > > BTW, I liked how you detected straights using the delta transform. Clever > idea (for me at least :). > > > > > # cleanup white space > > arranged_hand.gsub!(/\s+/, ' ') > > # careful to use gsub as gsub! can return nil here > > arranged_hand.gsub(/\s+$/, '') > > end > >