The goal of this exercise is to convert a string to a new string where each character in the new string is "(" if that character appears only once in the original string, or ")" if that character appears more than once in the original string. Ignore capitalization when determining if a character is a duplicate.
Examples
"Success" => ")())())"
"(( @" => "))(("
Tests
"din"
"recede"
Good luck!
This challenge comes from obnounce on CodeWars. Thank you to CodeWars, who has licensed redistribution of this challenge under the 2-Clause BSD License!
Want to propose a challenge idea for a future post? Email yo+challenge@dev.to with your suggestions!
Oldest comments (27)
My Haskell solution:
Python solution 🐍
Here is a C++ solution,
Here is the simple approach with nested for loops with PHP:
Here is a simple python code:

A simple (and somewhat slow) JS solution:
Not that slow :) Better than anything that searched/scanned or did an indexOf for sure! You know I like that || 1 as well, I always do (acc[val] || 0) + 1 - but that is much neater. Borrowing that.
Same to me
|| 0
Javascript solution:
Neat!
What is this syntax at the end?
join``
I always use
.join('').
That is Tagged template literals, to save 2 character :D
I forgot all about that syntax. I've probably only used it a few times.
Go
🐍
Python: