<commit_before>(ns allergies)

;;; Ruby's word array
(defmacro %w [& args] `(map str '~args))

(def allergies (%w eggs peanuts shellfish strawberries
                 tomatoes chocolate pollen cats))

(defn list
  "list of allergies for the given score"
  [score]
  (loop [s score
         allergy-num (dec (count allergies))
         acc []]
    (cond
     (<= s 0) acc
     (< allergy-num 0) acc
     :else (let [allergy-score (Math/pow 2 allergy-num)
                 allergy (nth allergies allergy-num)]
             (if (>= s allergy-score)
               (recur (- s allergy-score) (dec allergy-num) (conj acc allergy))
               (recur s (dec allergy-num) acc))))))

(defn allergic_to?
  "returns whether the given score includes the allergy"
  [score allergy]
  (contains? (list score) allergy))<commit_msg>list allergies in reverse order, check contains? on set.<commit_after>(ns allergies)

;;; Ruby's word array
(defmacro %w [& args] `(map str '~args))

(def allergies (%w eggs peanuts shellfish strawberries
                 tomatoes chocolate pollen cats))

(defn list
  "list of allergies for the given score"
  [score]
  (loop [s score
         allergy-num (dec (count allergies))
         acc []]
    (cond
     (<= s 0) acc
     (< allergy-num 0) acc
     :else (let [allergy-score (Math/pow 2 allergy-num)
                 allergy (nth allergies allergy-num)]
             (if (>= s allergy-score)
               (recur (- s allergy-score) (dec allergy-num) (cons allergy acc))
               (recur s (dec allergy-num) acc))))))

(defn allergic_to?
  "returns whether the given score includes the allergy"
  [score allergy]
  (contains? (set (list score)) allergy))
{'fraction_non_alphanumeric': 0.12137359384251035, 'fraction_numerical': 0.003552397868561279, 'mean_word_length': 2.4989648033126293, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '3079576', 'n_tokens_mistral': 553, 'n_tokens_neox': 501, 'n_words': 186}