Skip to content

Commit

Permalink
Slightly refactor tasks (#941)
Browse files Browse the repository at this point in the history
  • Loading branch information
solar05 committed Jun 16, 2022
1 parent 6cbf6c8 commit 0077a22
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/battle_asserts/issues/excel_sheet_column_number.clj
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
(defn pow [base exp]
(apply * (repeat exp base)))

(defn solution [s]
(defn solution [sheet]
(->>
s
clojure.string/reverse
sheet
s/reverse
char-array
(map-indexed #(* (- (int %2) 64) (pow 26 %1)))
(apply +)))
4 changes: 2 additions & 2 deletions src/battle_asserts/issues/read_roman_numerals.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns battle-asserts.issues.read-roman-numerals
(:require [clojure.pprint :as pprint]
[clojure.string]
[clojure.string :as s]
[clojure.test.check.generators :as gen]))

(def level :hard)
Expand Down Expand Up @@ -32,7 +32,7 @@

(defn solution [roman]
(let [numerals {\I 1, \V 5, \X 10, \L 50, \C 100, \D 500, \M 1000}]
(loop [roman-reverse (clojure.string/reverse roman) last-element 0 sum 0]
(loop [roman-reverse (s/reverse roman) last-element 0 sum 0]
(if (empty? roman-reverse)
sum
(let [value (numerals (first roman-reverse))
Expand Down
2 changes: 1 addition & 1 deletion src/battle_asserts/issues/reverse_each_word.clj
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@
(defn solution [string]
(->>
(s/split string #" ")
(map clojure.string/reverse)
(map s/reverse)
(s/join " ")))
10 changes: 5 additions & 5 deletions src/battle_asserts/issues/underscore.clj
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
(defn solution [string]
(->
string
(clojure.string/replace #"-" "_")
(clojure.string/replace #"([a-z\d])([A-Z])" "$1_$2")
(clojure.string/replace #"([A-Z+])([A-Z][a-z])" "$1_$2")
(clojure.string/replace #"::" "/")
clojure.string/lower-case))
(s/replace #"-" "_")
(s/replace #"([a-z\d])([A-Z])" "$1_$2")
(s/replace #"([A-Z+])([A-Z][a-z])" "$1_$2")
(s/replace #"::" "/")
s/lower-case))
2 changes: 1 addition & 1 deletion src/battle_asserts/issues/word_pattern.clj
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@
(defn solution [pattern words]
(=
(transform (vec (seq pattern)))
(transform (clojure.string/split words #" "))))
(transform (s/split words #" "))))

0 comments on commit 0077a22

Please sign in to comment.