aboutsummaryrefslogtreecommitdiff
path: root/codewars/6-kyu/duplicate-encoder/solution.hs
diff options
context:
space:
mode:
authorMistivia <i@mistivia.com>2024-01-27 14:16:01 +0800
committerMistivia <i@mistivia.com>2024-01-27 14:16:01 +0800
commit203658f4a5b8649d0142ab8ff6440eb0eefa48e9 (patch)
tree1ac871f3e5cdb91e7d29314ebd33ff8538558ee2 /codewars/6-kyu/duplicate-encoder/solution.hs
parent6580dcd9127f69aaa794472ec92bc46015dc4019 (diff)
rename folders
Diffstat (limited to 'codewars/6-kyu/duplicate-encoder/solution.hs')
-rw-r--r--codewars/6-kyu/duplicate-encoder/solution.hs18
1 files changed, 18 insertions, 0 deletions
diff --git a/codewars/6-kyu/duplicate-encoder/solution.hs b/codewars/6-kyu/duplicate-encoder/solution.hs
new file mode 100644
index 0000000..1cb38eb
--- /dev/null
+++ b/codewars/6-kyu/duplicate-encoder/solution.hs
@@ -0,0 +1,18 @@
+-- https://www.codewars.com/kata/54b42f9314d9229fd6000d9c
+
+module Dups where
+
+import Data.Char
+
+count s c
+ | s == [] = 0
+ | c == (head s) = 1 + count (tail s) c
+ | otherwise = count (tail s) c
+
+convert s c
+ | count s c > 1 = ')'
+ | otherwise = '('
+
+duplicateEncode :: String -> String
+duplicateEncode s = map (convert ls) ls
+ where ls = map toLower s