Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
Just another Perl shrine
 
PerlMonks  

Re: Re: tic-tac-toe regex golf (bug)

by barrachois (Pilgrim)
on Nov 18, 2003 at 12:11 UTC ( [id://308042]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re: tic-tac-toe regex golf (bug)
in thread tic-tac-toe regex golf

Yes, thank you.

That was just pointed out to me by someone else as well, and I've put an addendum and correction into the original post accordingly.

Following Dave's suggestion to use \w instead of X|O, the shortest I'm currently aware of is this 57 char regex which lists out the two .{2,3} cases explicitly.

^(...)*(\w)\2\2|^..(\w).\3.\3|(\w)..\4..\4|(\w)...\5...\5

Replies are listed 'Best First'.
Re: Re: Re: tic-tac-toe regex golf (bug)
by Anonymous Monk on Nov 19, 2003 at 19:41 UTC
    Sometimes it helps to anchor from the other side:
    (\w)(..(\1|.\1.)..\1|.\1.\1..$|\1\1(...)*$)
    This 43 also gets rid of all those ugly different digits, in favor of pleasing uniformity :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://308042]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.