If you want a challenge, try this one: http://twiki.org/p/pub/Codev/TWikiPresentation2013x03x07/reg...
https://devjoe.appspot.com/huntindex/puzzle/mit2013601
PDF: http://web.mit.edu/puzzle/www/2013/coinheist.com/rubik/a_reg...
41–50 of 97 posts
If you want a challenge, try this one: http://twiki.org/p/pub/Codev/TWikiPresentation2013x03x07/reg...
https://devjoe.appspot.com/huntindex/puzzle/mit2013601
PDF: http://web.mit.edu/puzzle/www/2013/coinheist.com/rubik/a_reg...
Earlier quoted context omitted.
This problem is NP-hard by reduction from SAT. Treat each column as a truth variable and use the rows to encode CNF clauses. For example, `(A | ^C)` becomes `(1..)|(..0)`. Then set all the column regexes to `( 0* )|( 1* )` to enforce a consistent truth value for each variable.
Could you elaborate on the encoding? What are valid mappings?
For an n x m grid, you can encode any CNF formula with n clauses on m variables. See here if you are unfamiliar with CNF: https://en.wikipedia.org/wiki/Conjunctive_normal_form
If you want a challenge, try this one: http://twiki.org/p/pub/Codev/TWikiPresentation2013x03x07/reg...
I've worked on the project where some XSD files defined fields with regex restrictions, also some rules over fields added other stricter regexps or negative regexps depending on some context in a format called Schematron. I had to generate XML files conforming to those XSD, so I used some tools around Z3 solver and Microsoft.Automata to generate those strings conforming to multiple regexps. It would convert the regex…
How did you solve backreferences with that approach?
If you want a challenge, try this one: http://twiki.org/p/pub/Codev/TWikiPresentation2013x03x07/reg...
Originally from the MIT Mystery Hunt: https://devjoe.appspot.com/huntindex/puzzle/mit2013601 PDF: http://web.mit.edu/puzzle/www/2013/coinheist.com/rubik/a_reg...
The puzzles generally don't tell you how to extract the answer, but the idea is you know it when you see it.
Regex is one of those tools that I use a couple times a year - usually for cleaning up lousy input data. I always end up spending a fair amount of time using tools like: http://regex.inginf.units.it/ https://regex101.com/ http://www.regexr.com/ And of course stackoverflow.
Does any common regex format/dialect require '\-' for a literal hyphen? AFAIK it's only special inside character classes, and escaping it doesn't necessarily work there if it would form a valid range identifier.
I suppose the two main benefits are
(a) neither the writer nor the reader has to remember which punctuation characters are meta-characters (you just have to remember that it's always a literal if it's escaped), and
(b) in implementations like PHP's which try to replicate the Perl-style 'delimited' syntax (e.g., /foo/), it prevents characters in the pattern from conflicting with the delimiters.
Maybe there's some other advantage but i can't think of what.
Worth doing this by hand to exercise your knowledge of regular expressions. My solution (SPOILER): http://imgur.com/a/9iK9J