We define the happiness level of a text as the number of occurrences
of subwords ":-)" and
"(-:".
We define the sadness level of a text as the number of occurrences of
subwords ":-(" and
")-:".
Implement a program such that, given a sequence of characters from
{’-’, ’:’, ’(’, ’)’}, prints its level of
happiness and sadness.
The input contains only one line with a sequence of characters from
{’-’, ’:’, ’(’, ’)’}.
The output has two numbers separated by a white space, the happiness and sadness levels of the input text.
Do not use strings nor any other massive
data storage method. Read and treat the input character by
character.
Input
)-:--(--::((:-:)):::))-(((--)(:))::-(((((-:((--(-((:-)))-:--(-:(-:))(---(-)-(-):)-:::))-::((-(:())--
Output
4 5
Input
:-)-:-(-:-)-::-((-:--)-::::--(-:
Output
5 5