Skip to content

Commit

Permalink
Fixed bug in Unique String data generation.
Browse files Browse the repository at this point in the history
  • Loading branch information
thelmuth committed Jan 28, 2021
1 parent a884f46 commit 9626a80
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/clojush/problems/software/benchmarks_v2/unique_string.clj
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 38,12 @@
Each string is of length [0, 10]"
[len]
(let [repeated-string (random-string (lrand-int 11))
the-vec (vec (repeat len repeated-string))]
the-vec (vec (repeat len repeated-string))
unique-string (first (filter #(not= % repeated-string)
(repeatedly #(random-string (lrand-int 11)))))]
(assoc the-vec
(lrand-int len)
(random-string (lrand-int 11)))))
unique-string)))

;; A list of data domains. Each domain is a vector containing
;; a "set" of inputs and two integers representing how many cases from the set
Expand Down Expand Up @@ -79,9 81,13 @@
(second vec-of-str)) (first vec-of-str)
(= (first vec-of-str)
(nth vec-of-str 2)) (first vec-of-str)
:else (second vec-of-str))]
(first (filter #(not= % the-repeat)
vec-of-str))))
:else (second vec-of-str))
answer (first (filter #(not= % the-repeat)
vec-of-str))]
(if (nil? answer)
(throw (Exception. (str "The following input vector to the Unique String
problem does not seem to have a unique string in it:" vec-of-str)))
answer)))

; Helper function for error function
(defn test-cases
Expand Down

0 comments on commit 9626a80

Please sign in to comment.