Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!husc6!necntc!ncoast!allbery From: bobk@mntgfx.MENTOR.COM (Bob Kelley) Newsgroups: comp.sources.misc Subject: Program to enumerate all words derivable from a telephone number Message-ID: <3747@ncoast.UUCP> Date: Tue, 4-Aug-87 20:28:33 EDT Article-I.D.: ncoast.3747 Posted: Tue Aug 4 20:28:33 1987 Date-Received: Thu, 6-Aug-87 07:26:44 EDT Sender: allbery@ncoast.UUCP Organization: Mentor Graphics, Beaverton OR Lines: 62 Keywords: telephone mnemonic Approved: allbery@ncoast.UUCP X-Archive: comp.sources.misc/8708/2 /* * enumerate all words derivable from a telephone number - phony.c * * Usage: phony * * Non-digits, '0', and '1' in the phone number are transcripted as is. * The digits '2' through '9' are cycled through their letter equivalents. * * I don't care what you do with this program, which was inspired by a * telephone number which I found impossible to remember. Robert J. Kelley 8/3/87 */ #include char *digits[] = { "abc", "def", "ghi", "jkl", "mno", "prs", "tuv", "wxy" }; char buf[32]; enumerate (s, b) char *s; char *b; { char *p; if (b >= buf + sizeof(buf)) { printf ("phony: Telephone number longer than 32 characters.\n"); exit (1); } if (*s == 0) printf ("%s\n", buf); else if ('2' <= *s && *s <= '9') { for (p = digits[*s - '2']; *p; ++p) { *b = *p; enumerate (s + 1, b + 1); } } else { *b = *s; enumerate (s + 1, b + 1); } } main (argc, argv) int argc; char **argv; { char *s; if (argc != 2) { printf ("usage: phony \n"); exit (1); } enumerate (argv[1], buf); }