-
-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
03f35fd
commit 20a6f4e
Showing
7 changed files
with
114 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
(ns diamond-generator) | ||
|
||
(defn update-test-case [test-case] | ||
(update-in test-case [:input :letter] first)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
(ns diamond-test | ||
(:require [clojure.test :refer [deftest testing is]] | ||
[clojure.string :as str] | ||
diamond)) | ||
|
||
{{#test_cases.rows}} | ||
(deftest diamond_test_{{idx}} | ||
(testing {{description}} | ||
(is (= (str/join "\n" [{{#expected}} | ||
{{.}}{{/expected}}]) | ||
(diamond/diamond {{input.letter}}))))) | ||
{{/test_cases.rows}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
(ns diamond) | ||
|
||
(defn diamond [] ;; <- arglist goes here | ||
;; your code goes here | ||
) | ||
(defn diamond | ||
"Returns the diamond shape for a letter." | ||
[letter] | ||
;; function body | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,91 @@ | ||
(ns diamond-test | ||
(:require [clojure.test :refer [deftest is are]] | ||
[diamond :refer [diamond]])) | ||
(:require [clojure.test :refer [deftest testing is]] | ||
[clojure.string :as str] | ||
diamond)) | ||
|
||
(deftest single-a-row | ||
(is (= (diamond \A) ["A"]))) | ||
(deftest diamond_test_1 | ||
(testing "Degenerate case with a single 'A' row" | ||
(is (= (str/join "\n" ["A"]) | ||
(diamond/diamond \A))))) | ||
|
||
(deftest b-diamond | ||
(is (= (diamond \B) [" A " | ||
"B B" | ||
" A "]))) | ||
(deftest c-diamond | ||
(is (= (diamond \C) [" A " | ||
" B B " | ||
"C C" | ||
" B B " | ||
" A "]))) | ||
(deftest diamond_test_2 | ||
(testing "Degenerate case with no row containing 3 distinct groups of spaces" | ||
(is (= (str/join "\n" [" A " | ||
"B B" | ||
" A "]) | ||
(diamond/diamond \B))))) | ||
|
||
(deftest d-diamond | ||
(is (= (diamond \D) [" A " | ||
" B B " | ||
" C C " | ||
"D D" | ||
" C C " | ||
" B B " | ||
" A "]))) | ||
(deftest diamond_test_3 | ||
(testing "Smallest non-degenerate case with odd diamond side length" | ||
(is (= (str/join "\n" [" A " | ||
" B B " | ||
"C C" | ||
" B B " | ||
" A "]) | ||
(diamond/diamond \C))))) | ||
|
||
(deftest full-z-diamond | ||
(is (= (diamond \Z) [" A " | ||
" B B " | ||
" C C " | ||
" D D " | ||
" E E " | ||
" F F " | ||
" G G " | ||
" H H " | ||
" I I " | ||
" J J " | ||
" K K " | ||
" L L " | ||
" M M " | ||
" N N " | ||
" O O " | ||
" P P " | ||
" Q Q " | ||
" R R " | ||
" S S " | ||
" T T " | ||
" U U " | ||
" V V " | ||
" W W " | ||
" X X " | ||
" Y Y " | ||
"Z Z" | ||
" Y Y " | ||
" X X " | ||
" W W " | ||
" V V " | ||
" U U " | ||
" T T " | ||
" S S " | ||
" R R " | ||
" Q Q " | ||
" P P " | ||
" O O " | ||
" N N " | ||
" M M " | ||
" L L " | ||
" K K " | ||
" J J " | ||
" I I " | ||
" H H " | ||
" G G " | ||
" F F " | ||
" E E " | ||
" D D " | ||
" C C " | ||
" B B " | ||
" A "]))) | ||
(deftest diamond_test_4 | ||
(testing "Smallest non-degenerate case with even diamond side length" | ||
(is (= (str/join "\n" [" A " | ||
" B B " | ||
" C C " | ||
"D D" | ||
" C C " | ||
" B B " | ||
" A "]) | ||
(diamond/diamond \D))))) | ||
|
||
(deftest diamond_test_5 | ||
(testing "Largest possible diamond" | ||
(is (= (str/join "\n" [" A " | ||
" B B " | ||
" C C " | ||
" D D " | ||
" E E " | ||
" F F " | ||
" G G " | ||
" H H " | ||
" I I " | ||
" J J " | ||
" K K " | ||
" L L " | ||
" M M " | ||
" N N " | ||
" O O " | ||
" P P " | ||
" Q Q " | ||
" R R " | ||
" S S " | ||
" T T " | ||
" U U " | ||
" V V " | ||
" W W " | ||
" X X " | ||
" Y Y " | ||
"Z Z" | ||
" Y Y " | ||
" X X " | ||
" W W " | ||
" V V " | ||
" U U " | ||
" T T " | ||
" S S " | ||
" R R " | ||
" Q Q " | ||
" P P " | ||
" O O " | ||
" N N " | ||
" M M " | ||
" L L " | ||
" K K " | ||
" J J " | ||
" I I " | ||
" H H " | ||
" G G " | ||
" F F " | ||
" E E " | ||
" D D " | ||
" C C " | ||
" B B " | ||
" A "]) | ||
(diamond/diamond \Z))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters