Fun project but fuzzy on logic. "PhoneCALLs"

Geoff Canyon gcanyon at inspiredlogic.com
Sat Sep 20 22:38:00 EDT 2003


Ignoring special cases like 0 and 1, each number can be represented by 
any of 3 letters, so there are 3^7 or 2187 combinations. The solution 
below includes q and z, so the range of possible solutions is 1 for any 
combination of 1s and 0s to 4^7 for any combination of 7s and 9s.

A recursive solution would handle this nicely:

local sSolution

on mouseUp
   put empty into sSolution
   doPerms "","2345678"
   put sSolution into fld 1
end mouseUp

on doPerms pString,pPhone
   if pPhone is empty then
     put pString & cr after sSolution
   else
     put char 1 of pPhone into tChar
     delete char 1 of pPhone
     repeat for each char c in item tChar of 
"1,abc,def,ghi,jkl,mno,pqrs,tuv,wxyz,0"
       doPerms (pString & c),pPhone
     end repeat
   end if
end doPerms


On Saturday, September 20, 2003, at 05:44  PM, Andy Burns wrote:

>
> ----- Original Message -----
> From: "Dar Scott" <dsc at swcp.com>
> To: <use-revolution at lists.runrev.com>
>> On Saturday, September 20, 2003, at 04:50 PM, Andy Burns wrote:
>>
>>> I remember a program that you could type in your phone number and it
>>> would
>>> give you all permutations of what possible words could be formed.
>>
>> You realize this could be 2000 to 16000 "words" depending on how many
>> sevens there are?
>>
>> Dar Scott
>
>
> Dar,
>
> The program will allow for just one phone number (for the 
> "returninfield"
> message) of seven digits to generate all possible permutations. The 
> logic of
> how to write that permutation code is what I don't grasp.
>
> I'm simply taking one phone number and sending back all the alphabetic
> (including 0 and 1 numeral) combinations that may or may not make 
> words.
>
> The results will be displayed in a possibly huge field for the user to
> scroll to see if something makes "word-sense", so to speak.
>
> Andy Burns
>
>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
>

regards,

Geoff Canyon
gcanyon at inspiredlogic.com




More information about the use-livecode mailing list