-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #202 from MrPhantomT/feature/converted_power_digit…
…s_sum converted power digits sum
- Loading branch information
Showing
4 changed files
with
24 additions
and
20 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,15 @@ | ||
(ns battle-asserts.issues.power-digits-sum | ||
(:require [clojure.test.check.generators :as gen] | ||
[faker.generate :as faker])) | ||
|
||
(def level :easy) | ||
|
||
(def description "Create a method to calculate sum of digits for 2**n | ||
For example, 2**15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.") | ||
|
||
(defn arguments-generator [] | ||
(gen/tuple (gen/choose 0 30))) | ||
|
||
(defn solution [n] | ||
(reduce + (map #(Character/digit % 10) | ||
(str (apply * (repeat n 2)))))) |
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,9 @@ | ||
(ns battle-asserts.issues.power-digits-sum-test | ||
(:require [clojure.test :refer :all] | ||
[clojure.test.check.properties :as prop :include-macros true] | ||
[clojure.test.check.clojure-test :as ct :include-macros true] | ||
[battle-asserts.issues.power-digits-sum :as issue])) | ||
|
||
(deftest test-solution | ||
(is (= 13 (issue/solution 8))) | ||
(is (= 26 (issue/solution 15)))) |
This file was deleted.
Oops, something went wrong.