This is the solution to the program, solved in python. The Question can be found in the Algorithm domain of Hackerrank.
Given a string consisting of letters, a, b and c, we can perform the following operation: Take any two adjacent distinct characters and replace them with the third character. For example, if ‘a’ and ‘c’ are adjacent, they can replaced by ‘b’. Find the smallest string which we can obtain by applying this operation repeatedly?
for c in x:
if c not in m:
if((xm['a']==0 and xm['b']==0 ) or (xm['a']==0 and xm['c']==0 ) or (xm['b']==0 and xm['c']==0)):
if((xm['a']%2==0 and xm['b']%2==0 and xm['c']%2==0) or (xm['a']%2==1 and xm['b']%2==1 and xm['c']%2==1)):
for i in range(0,input()):
Found Bugs, Comment them here !
Latest posts by Bikash Panda (see all)
- Firmata protocol with Raspberry Pi and Arduino - September 13, 2017
- IOT:Power outlet controlled from internet using WeMOS - August 9, 2017
- OSMC on Raspberry PI with Setup and Control using Android App - July 7, 2017