[<prev] [next>] [thread-next>] [day] [month] [year] [list]
```Date: Wed, 2 Mar 2016 21:44:28 +0100
From: magnum <john.magnum@...hmail.com>
To: john-users@...ts.openwall.com
Subject: Reverse T9 rule

Here's a brain exercise for anyone even more bored than me:

I got the idea to write a T9 rule that can convert phone numbers like
1-800-CALL-ATT into their real phone number (in this case 1-800-2255-288).

# magnum -> 624686
[List.Rules:T9]
l sa2 sb2 sc2 sd3 se3 sf3 sg4 sh4 si4 sj5 sk5 sl5 sm6 sn6 so6 sp7
sq7 sr7 ss7 st8 su8 sv8 sw9 sx9 sy9 sz9 s 0 Q

That was straight-forward albeit not incredibly useful. Anyway I also
got the idea to do the reverse. In that case, a number will produce lots
of candidates since each digit can mean one of up to four letters.
Here's where I cowardly gave up:

# Should do 624686 -> magnum (among many alternatives)
[List.Rules:9T]
s2[abc] s3[def] s4[ghi] s5[jkl] s6[mno] s7[pqrs] s8[tuv] s9[wxyz]
s0[ ] Q

The problem with this rule as written here is that given the input of
624686 it will replace *all* instances of "6" with either "m", "n" or
"o". So it will produce candidates like magmum or nagnun but never
magnum. Thus here's the challenge: Write a rule that actually works, as
efficiently as possible. Can it be accommplished at all? Perhaps we'd
need a new rule command?

This would be easy using Perl or something like that but this is all
about using rules and the preprocessor.

magnum

```