Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Regexp Creation

by kyle (Abbot)
on Jan 25, 2008 at 19:04 UTC ( [id://664338]=note: print w/replies, xml ) Need Help??


in reply to Regexp Creation

I've read your question three times, and I don't have an answer, but I want to make sure I understand the question.

The data involved are:

  1. A secret number
  2. A guess at what the secret number is (e.g., 1122)
  3. Some description of how the guess matches the secret number (e.g., two of the digits are in the secret number in the place that they were in the guess, and one of the digits is in the secret number but not in the place that it was in the guess).

What you want is a regular expression that will match every possible number that the secret number could be, given the data you have.

Additionally, you want to be able to add (1) another guess, and (2) more data about how that guess matches, and refine the regex further.

Is that correct?

Replies are listed 'Best First'.
Re^2: Regexp Creation
by artist (Parson) on Jan 25, 2008 at 19:12 UTC
    Yes, exactly. You have put very nicely in words.

    I have few more ways in mind. Based on the guess, it can generate set of numbers that matches the conditions. Example: (1122:2:1) can give the set: x112,1x12,12x2,122x. Later on I can combine the sets( cross product) to see, which combination works good ( instead of generating a possibly complex regexp)

    --Artist
      (1122:2:1) can give the set: x112,1x12,12x2,122x

      There you have me totally confused. Take the second element from your set, 1x12. The two digits in their correct positions must be the first and last, no? So that means that the 1 in third position must exist in the target string, but at a different position than in the "guess" string.

      Do you see the problem yet?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://664338]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-04-26 05:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found