6 kyu

Exclamation marks series #17: Put the exclamation marks and question marks on the balance - are they balanced?

3,357 of 7,314myjinxin2015

Description:

Each exclamation mark's weight is 2; each question mark's weight is 3. Putting two strings left and right on the balance - are they balanced?

If the left side is more heavy, return "Left"; if the right side is more heavy, return "Right"; if they are balanced, return "Balance".

Examples

"!!", "??"     -->  "Right"
"!??", "?!!"   -->  "Left"
"!?!!", "?!?"  -->  "Left"
"!!???!????", "??!!?!!!!!!!"  -->  "Balance"
-- For Haskell use the Comparison type defined in Preloaded code
-- data Comparison = Left | Right | Balance deriving (Show, Eq, Enum, Bounded)

balance :: String -> String -> Comparison

balance "!!" "??" == Right
balance "!??" "?!!" == Left
balance "!?!!" "?!?" == Left
balance "!!???!????" "??!!?!!!!!!!" == Balance
Fundamentals

Stats:

CreatedOct 10, 2016
PublishedOct 10, 2016
Warriors Trained9020
Total Skips841
Total Code Submissions16122
Total Times Completed7314
JavaScript Completions3183
PHP Completions653
Python Completions3357
Haskell Completions173
Ruby Completions91
Julia Completions6
Total Stars75
% of votes with a positive feedback rating93% of 1001
Total "Very Satisfied" Votes864
Total "Somewhat Satisfied" Votes127
Total "Not Satisfied" Votes10
Total Rank Assessments8
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • myjinxin2015 Avatar
  • suic Avatar
  • anter69 Avatar
  • user8476848 Avatar
  • donaldsebleung Avatar
  • user7657844 Avatar
  • Voile Avatar
  • stellartux Avatar
  • ejini战神 Avatar
  • saudiGuy Avatar
Ad