Text Me – A PowerShell Dialer Challenge

The Chairman is very fond of puzzles, ciphers and secret codes. All of which lend themselves to PowerShell. Today’s Intermediate level challenge falls into this category. Although some of the bonus elements might require a bit more skill.

When you look at a telephone keypad, you will see that there is an alphabetic layout with each digit. There may be cultural distinctions, but The Chairman is hoping not enough to prevent you from participating in this challenge. Using the alphabet layout on phone, write a PowerShell function to convert a simple word to its numeric equivalent. For example, on a US phone, ‘help’ can be converted to 4357.

The lazy and easy way, would be to do a 1-1 substitution between alphabet characters and numbers. But Iron Scripters are made of stronger metal. Since the letters are grouped by number, let that be your guide.


  • Limit word length to 5 word characters.
  • Write a function to convert the numeric “word” back into plain text.

14 Replies to “Text Me – A PowerShell Dialer Challenge”

    • Jeffery Hicks

      I like the use of Regex. To translate back you would need a dictionary file of words. You could convert the numeric value back into all possible permutations and only keep ones that are in the dictionary. Not saying it would be perfect.

      • Martin

        Thanks, I didn’t want to go with the dictionary since I would image that we do the “coding”, sending the message to someone else and the other person can do “decoding” without the need to have a shared dictionary … but that could only be done if we do it like Gustavo proposed below and that on the other hand would not match the example of “help” being “4357”.

        Anyhow I really like the challange, is there any way to subscribe with a newsletter when new ones arrives? 🙂

  1. Gustavo Pustai

    Hello everyone!

    This is my first contribution to Iron Scripter!

    I use hashtable to create the dialer. I Wrote a function to turn the numeric value back to text, but it not gives the same word.

    It would be nice if we convert the word considering the position on the keypad. Like “help” = 44335557 insted of 4357

    Anyway, this is my contribution:

  2. Scott

    Hi, i just found this site, Great idea!
    I will be back for more. Been PoShing a few years now. Have learned a LOT from so many blogs and posts.
    I don’t have a github. but here is my entry. Tried to give a more robust error error handling.

    # technique: find letter in delimited string, count delimiters
    Try{[ValidatePattern(‘^\w{1,5}$’)][string]$str = Read-host -Prompt ‘Enter your word ‘
    $arr = $str.ToCharArray()
    Catch{Write-Host ‘Invalid, 5 chars maximum, only letters and numbers’}
    }Until($arr -ne $null)
    ForEach($ltr in $arr){
    If($ltr -match ‘\d’){$result += $ltr}
    $result += (($b.ToCharArray().Where({$_ -match ‘\|’}) | Measure-Object -Character).Characters)


Comments are closed.