Skip to main content
2 of 9
shortened by 1 char
Cristian Lupascu
  • 8.7k
  • 2
  • 26
  • 52

GolfScript 54 53

' '/{1$1$?)0>{?}{\+}if}*2%{"UOK0D"\?).0>+.4>5*+}%{+}* 

The input has to be on the stack as a string, in the specified format (example: '7A UA DA').

In case the input is valid, the program prints the total value of the cards.

In case there's at least one duplicate card, the program throws the following exception:

undefined method `each' for 0:Fixnum (NoMethodError) 
Cristian Lupascu
  • 8.7k
  • 2
  • 26
  • 52