diff options
Diffstat (limited to 'leetcode/lc-1844-replace-all-digits-with-characters.rkt')
-rw-r--r-- | leetcode/lc-1844-replace-all-digits-with-characters.rkt | 18 |
1 files changed, 0 insertions, 18 deletions
diff --git a/leetcode/lc-1844-replace-all-digits-with-characters.rkt b/leetcode/lc-1844-replace-all-digits-with-characters.rkt deleted file mode 100644 index 96aba6e..0000000 --- a/leetcode/lc-1844-replace-all-digits-with-characters.rkt +++ /dev/null @@ -1,18 +0,0 @@ -#lang racket -(define/contract (replace-digits s) - (-> string? string?) - (define/contract (shift-letter c x) - (-> char? char? char?) - (integer->char (+ (string->number (string x)) (char->integer c)))) - (define letters (string->list (string-replace s #rx"[0-9]" ""))) - (define digits (string->list (string-replace s #rx"[a-z]" ""))) - (foldl (λ (c x acc) - (if (equal? x #\X) - (string-append acc (string c)) - (string-append acc (string c) (string (shift-letter c x))))) - "" - letters - (if (= (length digits) (length letters)) - digits - (append digits '(#\X))) - ))
\ No newline at end of file |