Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isogram: Sync tests #705

Merged
merged 8 commits into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion exercises/practice/isogram/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"AndreaCrotti",
"haus",
"sjwarner-bp",
"yurrriq"
"yurrriq",
"tasxatzial"
],
"files": {
"solution": [
Expand Down
13 changes: 9 additions & 4 deletions exercises/practice/isogram/.meta/example.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
(ns isogram
(:require [clojure.string :as str]))
(ns isogram)

(defn isogram? [word]
(apply distinct? (filter #(Character/isLetter %) (str/lower-case word))))
(defn isogram?
[s]
(->> s
clojure.string/lower-case
(filter #(Character/isAlphabetic (int %)))
frequencies
vals
(every? #{1})))
16 changes: 13 additions & 3 deletions exercises/practice/isogram/.meta/tests.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# This is an auto-generated file. Regular comments will be removed when this
# file is regenerated. Regenerating will not touch any manually added keys,
# so comments can be added in a "comment" key.
# This is an auto-generated file.
#
# Regenerating this file via `configlet sync` will:
# - Recreate every `description` key/value pair
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
# - Preserve any other key/value pair
#
# As user-added comments (using the # character) will be removed when this file
# is regenerated, comments can be added via a `comment` key.

[a0e97d2d-669e-47c7-8134-518a1e2c4555]
description = "empty string"
Expand Down Expand Up @@ -40,3 +47,6 @@ description = "duplicated character in the middle"

[310ac53d-8932-47bc-bbb4-b2b94f25a83e]
description = "same first and last characters"

[0d0b8644-0a1e-4a31-a432-2b3ee270d847]
description = "word with duplicated character and with two hyphens"
8 changes: 5 additions & 3 deletions exercises/practice/isogram/src/isogram.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
(ns isogram)

(defn isogram? [] ;; <- arglist goes here
;; your code goes here
)
(defn isogram?
"Returns true if the given string is an isogram; otherwise, returns false"
[s]
;; function body
)
70 changes: 56 additions & 14 deletions exercises/practice/isogram/test/isogram_test.clj
Original file line number Diff line number Diff line change
@@ -1,17 +1,59 @@
(ns isogram-test
(:require [clojure.test :refer [deftest is]]
(:require [clojure.test :refer [deftest testing is]]
isogram))

(deftest test-isograms
(is (isogram/isogram? "duplicates"))
(is (isogram/isogram? "subdermatoglyphic"))
(is (isogram/isogram? "thumbscrew-japingly"))
(is (isogram/isogram? "Hjelmqvist-Gryb-Zock-Pfund-Wax"))
(is (isogram/isogram? "Heizölrückstoßabdämpfung"))
(is (isogram/isogram? "Emily Jung Schwartzkopf")))

(deftest test-non-isograms
(is (not (isogram/isogram? "eleven")))
(is (not (isogram/isogram? "Alphabet")))
(is (not (isogram/isogram? "the quick brown fox")))
(is (not (isogram/isogram? "éléphant"))))
(deftest isogram?_test_1
(testing "empty string"
(is (true? (isogram/isogram? "")))))

(deftest isogram?_test_2
(testing "isogram with only lower case characters"
(is (true? (isogram/isogram? "isogram")))))

(deftest isogram?_test_3
(testing "word with one duplicated character"
(is (false? (isogram/isogram? "eleven")))))

(deftest isogram?_test_4
(testing "word with one duplicated character from the end of the alphabet"
(is (false? (isogram/isogram? "zzyzx")))))

(deftest isogram?_test_5
(testing "longest reported english isogram"
(is (true? (isogram/isogram? "subdermatoglyphic")))))

(deftest isogram?_test_6
(testing "word with duplicated character in mixed case"
(is (false? (isogram/isogram? "Alphabet")))))

(deftest isogram?_test_7
(testing "word with duplicated character in mixed case, lowercase first"
(is (false? (isogram/isogram? "alphAbet")))))

(deftest isogram?_test_8
(testing "hypothetical isogrammic word with hyphen"
(is (true? (isogram/isogram? "thumbscrew-japingly")))))

(deftest isogram?_test_9
(testing "hypothetical word with duplicated character following hyphen"
(is (false? (isogram/isogram? "thumbscrew-jappingly")))))

(deftest isogram?_test_10
(testing "isogram with duplicated hyphen"
(is (true? (isogram/isogram? "six-year-old")))))

(deftest isogram?_test_11
(testing "made-up name that is an isogram"
(is (true? (isogram/isogram? "Emily Jung Schwartzkopf")))))

(deftest isogram?_test_12
(testing "duplicated character in the middle"
(is (false? (isogram/isogram? "accentor")))))

(deftest isogram?_test_13
(testing "same first and last characters"
(is (false? (isogram/isogram? "angola")))))

(deftest isogram?_test_14
(testing "word with duplicated character and with two hyphens"
(is (false? (isogram/isogram? "up-to-date")))))