<commit_before>;;; -*- Gerbil -*-
;;; © vyzo
;;; :std/amb unit-test

(import :std/test
        :std/amb)
(export amb-test)

(def amb-test
  (test-suite "test :std/amb"
    (test-case "solve dwelling puzzle"
      (def (distinct? lst)
        (let lp ((rest lst))
          (match rest
            ([hd . rest]
             (and (not (memq hd rest))
                  (lp rest)))
            (else #t))))

      (def (solve-dwelling-puzzle)
        (let ((baker (amb 1 2 3 4 5))
              (cooper (amb 1 2 3 4 5))
              (fletcher (amb 1 2 3 4 5))
              (miller (amb 1 2 3 4 5))
              (smith (amb 1 2 3 4 5)))

          ;; They live on different floors.
          (required (distinct? (list baker cooper fletcher miller smith)))

          ;; Baker does not live on the top floor.
          (required (not (= baker 5)))

          ;; Cooper does not live on the bottom floor.
          (required (not (= cooper 1)))

          ;; Fletcher does not live on either the top or the bottom floor.
          (required (not (= fletcher 5)))
          (required (not (= fletcher 1)))

          ;; Miller lives on a higher floor than does Cooper.
          (required (> miller cooper))

          ;; Smith does not live on a floor adjacent to Fletcher's.
          (required (not (= (abs (- smith fletcher)) 1)))

          ;; Fletcher does not live on a floor adjacent to Cooper's.
          (required (not (= (abs (- fletcher cooper)) 1)))

          `((baker ,baker) (cooper ,cooper) (fletcher ,fletcher) (miller ,miller) (smith ,smith))))

      (check (solve-dwelling-puzzle) => '((baker 3) (cooper 2) (fletcher 4) (miller 5) (smith 1))))))<commit_msg>Add begin-amb and revert use of element-of<commit_after>;;; -*- Gerbil -*-
;;; © vyzo
;;; :std/amb unit-test

(import :std/test
        :std/amb)
(export amb-test)

(def amb-test
  (test-suite "test :std/amb"
    (test-case "solve dwelling puzzle"
      (def (distinct? lst)
        (let lp ((rest lst))
          (match rest
            ([hd . rest]
             (and (not (memq hd rest))
                  (lp rest)))
            (else #t))))

      (def (solve-dwelling-puzzle)
        (begin-amb
         (let ((baker (amb 1 2 3 4 5))
               (cooper (amb 1 2 3 4 5))
               (fletcher (amb 1 2 3 4 5))
               (miller (amb 1 2 3 4 5))
               (smith (amb 1 2 3 4 5)))

           ;; They live on different floors.
           (required (distinct? (list baker cooper fletcher miller smith)))

           ;; Baker does not live on the top floor.
           (required (not (= baker 5)))

           ;; Cooper does not live on the bottom floor.
           (required (not (= cooper 1)))

           ;; Fletcher does not live on either the top or the bottom floor.
           (required (not (= fletcher 5)))
           (required (not (= fletcher 1)))

           ;; Miller lives on a higher floor than does Cooper.
           (required (> miller cooper))

           ;; Smith does not live on a floor adjacent to Fletcher's.
           (required (not (= (abs (- smith fletcher)) 1)))

           ;; Fletcher does not live on a floor adjacent to Cooper's.
           (required (not (= (abs (- fletcher cooper)) 1)))

           `((baker ,baker) (cooper ,cooper) (fletcher ,fletcher) (miller ,miller) (smith ,smith)))))

      (check (solve-dwelling-puzzle) => '((baker 3) (cooper 2) (fletcher 4) (miller 5) (smith 1))))))
{'fraction_non_alphanumeric': 0.13646990064289888, 'fraction_numerical': 0.02104032729398013, 'mean_word_length': 1.8057377049180328, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4781691', 'n_tokens_mistral': 1175, 'n_tokens_neox': 1011, 'n_words': 408}