GREEK-EDITORIAL

PROBLEM LINK:

Practice

Contest

Author: Mrudula Kulkarni

Tester: Mrudula Kulkarni

Editorialist: Mrudula Kulkarni

DIFFICULTY:

Cakewalk

PREREQUISITES:

Implementation

PROBLEM:

In order to telegraph the ternary number the Greek alphabet is used. Digit 0 is transmitted as <<.>> , 1 as <<−.>> and 2 as <<−−>>. You need to decode the Greek code.

EXPLANATION :

To solve this problem, we need to traverse through the given string, map the code and store it in the other string. And finally, print the string in which we have mapped the code.

SOLUTION:

Setter's Solution

#include<bits/stdc++.h>
using namespace std;
int main()
{
string borze_code, translation;
cin >> borze_code;

for(unsigned int i = 0; i < borze_code.size(); i++)
{
    if(borze_code[i] == '.')
        translation += '0';
    else if(borze_code[i] == '-')
    {
        if(borze_code[i + 1] == '.')
            translation += '1';
        else if(borze_code[i + 1] == '-')
            translation += '2';

        i++;
    }
}

cout << translation;
return 0;

}