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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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/src/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 test-a0e97d2d-669e-47c7-8134-518a1e2c4555
(testing "empty string"
(is (true? (isogram/isogram? "")))))

(deftest test-9a001b50-f194-4143-bc29-2af5ec1ef652
(testing "isogram with only lower case characters"
(is (true? (isogram/isogram? "isogram")))))

(deftest test-8ddb0ca3-276e-4f8b-89da-d95d5bae78a4
(testing "word with one duplicated character"
(is (false? (isogram/isogram? "eleven")))))

(deftest test-6450b333-cbc2-4b24-a723-0b459b34fe18
(testing "word with one duplicated character from the end of the alphabet"
(is (false? (isogram/isogram? "zzyzx")))))

(deftest test-a15ff557-dd04-4764-99e7-02cc1a385863
(testing "longest reported english isogram"
(is (true? (isogram/isogram? "subdermatoglyphic")))))

(deftest test-f1a7f6c7-a42f-4915-91d7-35b2ea11c92e
(testing "word with duplicated character in mixed case"
(is (false? (isogram/isogram? "Alphabet")))))

(deftest test-14a4f3c1-3b47-4695-b645-53d328298942
(testing "word with duplicated character in mixed case, lowercase first"
(is (false? (isogram/isogram? "alphAbet")))))

(deftest test-423b850c-7090-4a8a-b057-97f1cadd7c42
(testing "hypothetical isogrammic word with hyphen"
(is (true? (isogram/isogram? "thumbscrew-japingly")))))

(deftest test-93dbeaa0-3c5a-45c2-8b25-428b8eacd4f2
(testing "hypothetical word with duplicated character following hyphen"
(is (false? (isogram/isogram? "thumbscrew-jappingly")))))

(deftest test-36b30e5c-173f-49c6-a515-93a3e825553f
(testing "isogram with duplicated hyphen"
(is (true? (isogram/isogram? "six-year-old")))))

(deftest test-cdabafa0-c9f4-4c1f-b142-689c6ee17d93
(testing "made-up name that is an isogram"
(is (true? (isogram/isogram? "Emily Jung Schwartzkopf")))))

(deftest test-5fc61048-d74e-48fd-bc34-abfc21552d4d
(testing "duplicated character in the middle"
(is (false? (isogram/isogram? "accentor")))))

(deftest test-310ac53d-8932-47bc-bbb4-b2b94f25a83e
(testing "same first and last characters"
(is (false? (isogram/isogram? "angola")))))

(deftest test-0d0b8644-0a1e-4a31-a432-2b3ee270d847
(testing "word with duplicated character and with two hyphens"
(is (false? (isogram/isogram? "up-to-date")))))
Loading