;;; -*- Mode:LISP; Package:USER; Readtable:CL; Base:10 -*- (defconst digit-letters '((0) (1) (#\a #\b #\c) (#\d #\e #\f) (#\g #\h #\i) (#\j #\k #\l) (#\m #\n #\o) (#\p #\r #\s) (#\t #\u #\v) (#\w #\x #\y))) ; ((T U V) (M N O) (G H I) - (P R S) (D E F) (D E F) (J K L)) (defun tw (num) (loop for l in (cross-n (tw-explode num)) (let ((a (make-string (length l)))) (loop for q in l for i from 0 (setf (aref a i) q)) (format t "~&~a" a)))) (defun tw-explode (num) (loop for i below (string-length num) collect (let ((dig (aref num i))) (if (and (>= dig #\0) (<= dig #\9)) (setq dig (nth (- dig #\0) digit-letters)) (setq dig (list dig))) dig))) (defun cross-n (l &aux (c '(nil))) (loop for q in l (setq c (cross c q))) c) (defun cross (l1 l2) (loop for p in l1 append (loop for q in l2 collect (append p (list q)))))