The input of this exercise is a sequence of characters over {a,b,c,d}. We want to count two things:
Input
The input is a sequence of characters over {a,b,c,d}, in just one line.
Output
The output has two natural numbers, in one line, and separated by a white space:
Observation
It is not allowed to use any massive storage data structure, not even string. Read and treat the input character by character.
Assessment over 10 points:
We understand as fast solution one being correct, with linear cost and able to overcome both the public and private tests. We understand as slow solution one not being fast, but correct and able to overcome the public tests.
Input
cdbdadccbdcacbbdcdadacacadbcd
Output
5 5
Input
bbabddccdcdcddddcdcadccbddcabbbbaaaccdcdccdddcaadcdcccdcaaddcdcdddccddcbbaadddcacdddcddbacdcccaccbabdcbddcdcdddcdcdcdcbdddcddbabcacddccddcdccccc
Output
36 23