aboutsummaryrefslogtreecommitdiff
path: root/racket/leetcode/lc-345-reverse-vowels.rkt
blob: c05bf2d3a2d2a904744cdc1300456dc1bca90490 (plain)
1
2
3
4
5
6
7
8
9
#lang racket

(define/contract (reverse-vowels s)
  (-> string? string?)
  (define vowels-only
    (string-replace s #rx"[^aeiouAEIOU]" ""))
  (define consonants-with-placeholders
    (string-replace s #rx"[aeiouAEIOU]" "~a"))
  (apply format consonants-with-placeholders (reverse (string->list vowels-only))))