Skip to content

Commit

Permalink
Merge pull request #202 from MrPhantomT/feature/converted_power_digit…
Browse files Browse the repository at this point in the history
…s_sum

converted power digits sum
  • Loading branch information
mokevnin committed Oct 16, 2015
2 parents cefe9e9 + 863ef54 commit 10b965c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 20 deletions.
9 changes: 0 additions & 9 deletions source/power_digits_sum.yml

This file was deleted.

15 changes: 15 additions & 0 deletions src/battle_asserts/issues/power_digits_sum.clj
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))))))
9 changes: 9 additions & 0 deletions test/battle_asserts/issues/power_digits_sum_test.clj
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))))
11 changes: 0 additions & 11 deletions test/issues/power_digits_sum_test.clj.bak

This file was deleted.

0 comments on commit 10b965c

Please sign in to comment.