Jump to content
czardas

Directory Enquiries Challenge

Recommended Posts

Why include unnecessary information, can you run the numbers through TAPI or Skype and log the return of the connection attempt?  Then you know whether or not, for certain, there is a device that answers; and you need nothing more than a list of numbers to run through your dialer...

Edited by iamtheky
frmt

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

Here's another approach using a UDF from JCHD named Typos.au3. This code will find close matches as well.

#include <Array.au3>
#include "typos.au3"
;; need to update country calling codes based on
;;;; https://en.wikipedia.org/wiki/List_of_country_calling_codes0
;;; and exit codes http://www.howtocallabroad.com/codes.html

#cs looking for
882 8565
123 8762
7543010
07843 543287
00441619346534
+44208.....missing numbers [optional task]
0015417543012
#ce

Local $aArray = _
    ['+262 692 12 03 00', '1800 251 996',    '+1 994 951 0197', _
    '091 535 98 91 61',   '2397865',         '08457 128276', _
    '348476300192',       '05842 361774',    '0-800-022-5649', _
    '15499514891',        '0096 363 0949',   '04813137349', _
    '06620 220168',       '07766 554433',    '047 845 44 22 94', _
    '0435 773 4859',      '(01) 882 8565',   '00441619346434', _
    '09314 367090',       '0 164 268 0887',  '0590995603', _
    '991',                '0267 746 3393',   '064157526153', _
    '0 719 829 7756',     '+1-541-754-3012', '+441347543010', _
    '03890 978398',       '(31) 10 7765420', '020 8568 6646', _
    '0161 934 6534',      '0 637 915 1283',  '+44 207 882 8565', _
    '0800 275002',        '0750 646 9746',   '982-714-3119', _
    '000 300 74 52 40',   '023077529227',    '1 758 441 0611', _
    '0183 233 0151',      '02047092863',     '+44 20 7946 0321', _
    '04935 410618',       '048 257 67 60 79']


Local $findnumb = _
    ['882 8565','123 8762','7543010','07843 543287','00441619346534','+44208.....missing numbers [optional task]','0015417543012']

For $i = 0 to Ubound($findnumb)-1 ; find these numbers!
    $reference = StringRegExpReplace($findnumb[$i],"[^0-9]","") ; Santize Numbers

    For $a = 0 to ubound($aArray)-1
        $dbnumbers = StringRegExpReplace($aArray[$a],"[^0-9]","")
        if Stringlen($reference) > Stringlen($dbnumbers) Then ContinueLoop
        $typos = _Typos($dbnumbers, $reference)
        IF $typos <= 5 then consolewrite(''& $typos & ' for Phone Number to look for '& $reference & ' and found number in DB '& $dbnumbers & ' at row '& $a & @CRLF)
    Next
Next

 

Share this post


Link to post
Share on other sites
1 hour ago, argumentum said:

a phone number that has clues. The are separated/spaced as they would in the geographical point of origin but may be incomplete. That requires a function that would take each number and consider it as from each known area and that, in itself, is not a short piece of code. All I've got so far is the country codes:

Global $aCCodes[212][2] = [[211,""], _

The next step would be to match what area/country would use that notation and if it's a complete number. Then,.... I'll just wait to see what was the better approach.

Note to the winner: if you use the array I put together you'd owe me a drop of the coins of your admirers ;) ( if you so choose, oh, you, mighty one )

Beat you to it ;-) I also found that he had WAY more possible real numbers than expected. But it doesn't necessarily specifically find the numbers he gave because some of the numbers to look for have a couple numbers changed and don't match anything in the "numbers" database without some ASM.

Edited by stamandster

Share this post


Link to post
Share on other sites

Here is my OCD kicking in again, I have added a hint to my previous post (#60)


A cross-platform implementation of the AutoIt language

My contributions to the AutoIt Community ##AutoIt at freenode, real-time chat

3fHNZJ.gif

Spoiler

If I have hurt or offended you in anyway, Please accept my apologies, I never (regardless of the situation) intend to do that to anybody.

Share this post


Link to post
Share on other sites

My OCD cannot contain itself anymore... I have added another BIG hint to my original post.


A cross-platform implementation of the AutoIt language

My contributions to the AutoIt Community ##AutoIt at freenode, real-time chat

3fHNZJ.gif

Spoiler

If I have hurt or offended you in anyway, Please accept my apologies, I never (regardless of the situation) intend to do that to anybody.

Share this post


Link to post
Share on other sites

I haven't had much time to code over the last two days. Anyway I have made some progress in creating a nearly coherent set of rules. My first attempt assumed that you either drop zero after the country code, or you do nothing. According to the link I posted earlier, there are only a few countries that don't do this. Three of these exceptions should already be handled without any tweaks to my original code: Hungary, Ukraine and Uzbekistan.

The only tricky numbers left to deal with appear to be mobiles in Argentina, Brazil, Colombia and Mexico.

Exceptions to the drop zero rule are:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Remove 7 after country code +213
; Algeria +213

; Remove 8 after country codes: +7 +370 +375 +992 +993 +994 +995 +998
; Azerbaijan +994, Belarus +375, Georgia +995, Kazakhstan +7, Lithuania +370,
; Russia +7, Tajikistan +992, Turkmenistan +993, Uzbekistan +998 [Uzbekistan +99 with no change]

; Remove 06 after country code +36 [similar to country code = +3 with zero removed]
; Hungary +36

; Remove 21 after the country code +356
; Malta +356

; Remove 22 after country code +231
; Liberia +231

; Remove 80 after country code +380 [similar to country code = +3 with no change]
; Ukraine +380
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Oddball Exceptions

; Argentina +54 last 8 digits must match ... 0 XX 15 XXXXXXXX ==> +54 9 XX XXXXXXXX [MOB] ==> [same length = 13 without Int Code]
;   0   XX 15 8Digits
; +54 9 XX    8Digits

; Brazil +55 - last 8 digits must match
; Colombia +57 - last 7 digits must match
; Mexico +52 - last 10 digits must match
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Nearly there!

Edited by czardas

Share this post


Link to post
Share on other sites
5 minutes ago, czardas said:

I haven't had much time to code over the last two days. Anyway I have made some progress in creating a nearly coherent set of rules. My first attempt assumed that you either drop zero after the country code, or you do nothing. According to the link I posted earlier, there are only a few countries that don't do this. Three of these exceptions should already be handled without any tweaks to my original code: Hungary, Ukraine and Uzbekistan.

The only tricky numbers left to deal with appear to be mobiles in Argentina, Brazil, Colombia and Mexico.

Exceptions to the drop zero rule are:

 

Nearly there!

What about local only exchange numbers?

Share this post


Link to post
Share on other sites

In the numbers to look for there are three local numbers and a couple are off by a number or two. Not all the telephone numbers we are asked to look for exist in the exact way in the larger numbers list unless you use ASM.

Edited by stamandster

Share this post


Link to post
Share on other sites

I believe that the following do not have exact matches (even if you remove spaces from reference numbers and larger list; replying on my phone so I can't really do the search for them well atm) but I do like where your going w your code! Adds some nice structure and rules to finding all phone numbers not just the ones presented.

123 8762
7543010
Edited by stamandster

Share this post


Link to post
Share on other sites
7543010 = +441347543010 found at index: 26

This is a possible match for local number 0134 754 3010 which may exist in the UK. The idea is to net all the fish and if some of them are the wrong, you can throw them back. This number may be the one you want to find.

Another example (882 8565) returns two matches. They can't both be correct, but you wouldn't want to assume the first one to be correct: either of them may be the number you want to find.

Edited by czardas

Share this post


Link to post
Share on other sites

Yeah :-) like i said, probably have wrong numbers as examples. Once I run my script again later I can output and show you what I mean. My last script finds all challenge numbers. My first script finds all real numbers in the larger list no matter the challenge questions. Try it out :-)

Edited by stamandster

Share this post


Link to post
Share on other sites
14 hours ago, czardas said:

I don't know why this turned out to be so complicated. All you are required to do is find a phone number.

You have been on the forums since 06 and you have gall to say something like that?

Lets alter this, and you will see why i say what i said.

Quote

I don't know why this turned out to be so complicated. All you are required to do is find  the a phone number help file and use it.

Now, how many times has this been told to people? :muttley:

"Easy" is easy to say, but more complicated to do.

Share this post


Link to post
Share on other sites
9 minutes ago, stamandster said:

Yeah :-) like i said, probably have wrong numbers as examples. Once I run my script again later I can output and show you what I mean. My last script finds all challenge numbers. My first script finds all real numbers in the larger list no matter the challenge questions. Try it out :-)

Typos.au3 is unsuitable for this. The method returns matches which are obviously wrong. It's an interesting idea, but fails terribly.

Share this post


Link to post
Share on other sites
5 minutes ago, czardas said:

Typos.au3 is unsuitable for this. The method returns matches which are obviously wrong. It's an interesting idea, but fails terribly.

Fails terribly, a little harsh. And why? Not all challenge the numbers are exactly in the list as provided (stringinstr will give you most numbers, provided you sanitize some), there are some with a number different. That's the only way to reconcile. Typos gives a "error" value that perhaps the end user meant to search for a different number in the database.

Edited by stamandster

Share this post


Link to post
Share on other sites
4 minutes ago, czardas said:

Because deviations should only occur in the first few digits. Typos.au3 looks for deviations at any position in the number. This is simply too greedy.

Deviations can exist anywhere. Phone numbers are generally typed w correct amount of numbers but many times a number here or there is substituted for another.

Typos will give you closest match, whether exact, hidden within or off by one or two numbers. I would say that deviation would occur more often in the last 7 digits than the beginning.

Edited by stamandster

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...