Daily Routine |Programming_info || python_problem_09

 Brendon is a little techno-whiz whose IQ is out of the charts. He has set up a laboratory at home for his research and development and was once approached by an Event Management firm to design them a Robot that would log all the activities carried out in an event at various instants during the day. This would help them keep a track and in smooth functioning of events.

Brendon, after long days of hard work designed one such Robot but wanted to test it on his own daily routines. His daily routine is very simple, he starts his day working in a computer, then he eats food and finally proceeds for sleeping thus ending his day. He has programmed his Robot to log the activities of him at various instants during the day.
Today it recorded activities that Brendon was doing at N different instants. These instances are recorded in chronological order (in increasing order of time). This log is provided to you in form of a string s of length N, consisting of characters 'C', 'E' and 'S'. If s[i] = 'C', then it means that at the i-th instant Brendon was working in Computer, 'E' denoting he was eating and 'S' means he was sleeping.
Write a program to tell whether the record log made by the robot could possibly be correct or not.

Input Format:
The only line of input contains the string s.

Output Format:
Output a single line containing "yes" or "no" (without quotes) accordingly.
Refer sample input and output for formatting specifications.

Sample Input 1:
CES

Sample Output 1:
yes

Sample Input 2:
SCCC

Sample Output 2:
no

Solution:
x=input()
a=0
for i in range(len(x)-1):
    if x[i]=='C':
        if x[i+1]=='C' or x[i+1]=='S' or x[i+1]=='E':
            a+=1
    elif x[i]=='E':
        if x[i+1]=='E' or x[i+1]=='S':
            a+=1
    elif x[i]=='S':
        if x[i+1]=='S':
            a+=1

if(a==len(x)-1):
    print("yes")
else:
    print("no")
Share:

No comments:

Post a Comment

Translate

Recommended platforms

  1. codechef
  2. hackerrank
  3. codeforces
  4. leetcode
  5. hackerearth

Popular Posts

programming_info. Powered by Blogger.

Recent Posts

other platforms

  • geeks for geeks
  • w3schools
  • codepen
  • skillshare
  • udemy

Pages

reader support Support