-
-
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.
Sum of multiples: Sync with problem-specifications (#579)
* Sync metadata * Implement & update tests
- Loading branch information
1 parent
762588c
commit bf9341f
Showing
3 changed files
with
49 additions
and
27 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
72 changes: 46 additions & 26 deletions
72
exercises/practice/sum-of-multiples/test/sum_of_multiples_test.clj
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,39 +1,59 @@ | ||
(ns sum-of-multiples-test | ||
(:require [clojure.test :refer [deftest is]] | ||
sum-of-multiples)) | ||
(:require [clojure.test :refer [deftest testing is]] | ||
[sum-of-multiples :refer [sum-of-multiples]])) | ||
|
||
(deftest sum-to-1 | ||
(is (zero? (sum-of-multiples/sum-of-multiples '(3 5) 1)))) | ||
(deftest no-multiples | ||
(testing "No multiples within limit" | ||
(is (zero? (sum-of-multiples '(3 5) 1))))) | ||
|
||
(deftest sum-to-4 | ||
(is (= 3 (sum-of-multiples/sum-of-multiples '(3 5) 4)))) | ||
(deftest one-factor-multiples | ||
(testing "One factor has multiples within limit" | ||
(is (= 3 (sum-of-multiples '(3 5) 4))))) | ||
|
||
(deftest sum-to-10 | ||
(is (= 23 (sum-of-multiples/sum-of-multiples '(3 5) 10)))) | ||
(deftest more-than-one-multiple | ||
(testing "More than one multiple within limit" | ||
(is (= 9 (sum-of-multiples '(3) 7))))) | ||
|
||
(deftest sum-to-100 | ||
(is (= 2318 (sum-of-multiples/sum-of-multiples '(3 5) 100)))) | ||
(deftest more-than-one-factor-multiples | ||
(testing "More than one factor with multiples within limit" | ||
(is (= 23 (sum-of-multiples '(3 5) 10))))) | ||
|
||
(deftest sum-to-1000 | ||
(is (= 233168 (sum-of-multiples/sum-of-multiples '(3 5) 1000)))) | ||
(deftest count-multiples-once | ||
(testing "Each multiple is only counted once" | ||
(is (= 2318 (sum-of-multiples '(3 5) 100))))) | ||
|
||
(deftest sum-to-20-using-7-13-17 | ||
(is (= 51 (sum-of-multiples/sum-of-multiples '(7 13 17) 20)))) | ||
(deftest larger-limit | ||
(testing "A much larger limit" | ||
(is (= 233168 (sum-of-multiples '(3 5) 1000))))) | ||
|
||
(deftest sum-to-15-using-4-6 | ||
(is (= 30 (sum-of-multiples/sum-of-multiples '(4 6) 15)))) | ||
(deftest three-factors | ||
(testing "Three factors" | ||
(is (= 51 (sum-of-multiples '(7 13 17) 20))))) | ||
|
||
(deftest sum-to-150-using-5-6-8 | ||
(is (= 4419 (sum-of-multiples/sum-of-multiples '(5 6 8) 150)))) | ||
(deftest factors-not-relatively-prime | ||
(testing "Factors not relatively prime" | ||
(is (= 30 (sum-of-multiples '(4 6) 15))))) | ||
|
||
(deftest sum-to-51-using-5-25 | ||
(is (= 275 (sum-of-multiples/sum-of-multiples '(5 25) 51)))) | ||
(deftest some-factors-relatively-prime | ||
(testing "Some pairs of factors relatively prime and some not" | ||
(is (= 4419 (sum-of-multiples '(5 6 8) 150))))) | ||
|
||
(deftest sum-to-10_000-using-43-47 | ||
(is (= 2203160 (sum-of-multiples/sum-of-multiples '(43 47) 10000)))) | ||
(deftest factor-multiple-of-other-factor | ||
(testing "One factor is a multiple of another" | ||
(is (= 275 (sum-of-multiples '(5 25) 51))))) | ||
|
||
(deftest sum-to-100-using-1 | ||
(is (= 4950 (sum-of-multiples/sum-of-multiples '(1) 100)))) | ||
(deftest larger-factors | ||
(testing "Much larger factors" | ||
(is (= 2203160 (sum-of-multiples '(43 47) 10000))))) | ||
|
||
(deftest sum-to-10_000-using-empty | ||
(is (zero? (sum-of-multiples/sum-of-multiples '() 10000)))) | ||
(deftest all-factors-multiples-of-1 | ||
(testing "All factors are multiples of 1" | ||
(is (= 4950 (sum-of-multiples '(1) 100))))) | ||
|
||
(deftest no-factors | ||
(testing "No factors means sum is 0" | ||
(is (zero? (sum-of-multiples '() 10000))))) | ||
|
||
(deftest more-than-three-factors | ||
(testing "More than 3 factors" | ||
(is (= 39614537 (sum-of-multiples '(2 3 5 7 11) 10000))))) |