<commit_before>#lang racket
(require Racket-miniKanren/miniKanren/mk)

(define assocs1
  '((#\a . #\4)
    (#\b . #\6)
    (#\e . #\3)
    (#\i . #\1)
    (#\l . #\1)
    (#\o . #\0)
    (#\s . #\5)
    (#\t . #\7)))

(define (noneo a bs)
  (conde
   ((== bs '()))
   
   ((fresh (bh bt)
      (== `(,bh . ,bt) bs)
      (=/= a bh)
      (noneo a bt)))))

(define (unify-pairs a b pairs)
  (match pairs
    ['() (fresh (x) (=/= x x))]
    [`((,ap . ,bp) . ,tail)
     (conde
      ((== ap a)
       (== bp b))

      ((unify-pairs a b tail)))]))

(define (leeto in out)
  (conde
   ((== in '())
    (== out '()))
   
   ((fresh (ih it oh ot)
      (== `(,ih . ,it) in)
      (== `(,oh . ,ot) out)
      (leeto it ot)
      (conde
       ((unify-pairs ih oh assocs1))
       
       ((noneo ih (map car assocs1))
        (noneo oh (map cdr assocs1))
        (== ih oh)))))))

(define (convert s)
  (let ([input (string->list s)])
    (map list->string
         (run* (q)
           (conde
            ((leeto q input))
            ((leeto input q)))))))<commit_msg>change implementation to use conde*<commit_after>#lang racket
(require Racket-miniKanren/miniKanren/mk)

(module+ test (require rackunit))

(define assocs1
  '((#\a . #\4)
    (#\b . #\6)
    (#\e . #\3)
    (#\i . #\1)
    (#\l . #\1)
    (#\o . #\0)
    (#\s . #\5)
    (#\t . #\7)))

(define (noneo a bs)
  (conde
   ((== bs '()))
   
   ((fresh (bh bt)
      (== `(,bh . ,bt) bs)
      (=/= a bh)
      (noneo a bt)))))

(define (conde* cs)
  (match cs
    ['()         (fresh (x) (=/= x x))]
    [(cons x xs) (conde ((fresh () x)) ((conde* xs)))]))

(define (leeto in out)
  (conde
   ((== in '())
    (== out '()))
   
   ((fresh (ih it oh ot)
      (== `(,ih . ,it) in)
      (== `(,oh . ,ot) out)
      (leeto it ot)
      (conde* (cons (fresh ()
                      (noneo ih (map car assocs1))
                      (noneo oh (map cdr assocs1))
                      (== ih oh))

                    (map (λ (pair) (fresh ()
                                     (== ih (car pair))
                                     (== oh (cdr pair))))
                         assocs1)))))))

(define (convert s)
  (let ([input (string->list s)])
    (map list->string
         (run* (q)
           (conde
            ((leeto q input))
            ((leeto input q)))))))

(module+ test
  (check-equal? (convert "elite") '("31173"))
  (check-equal? (convert "31173") '("eiite" "elite" "eilte" "ellte")))

{'fraction_non_alphanumeric': 0.23317112733171128, 'fraction_numerical': 0.013787510137875101, 'mean_word_length': 1.5045685279187817, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1540656', 'n_tokens_mistral': 1043, 'n_tokens_neox': 983, 'n_words': 259}