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)
- OSMC on Raspberry PI with Setup and Control using Android App - July 7, 2017
- DHT12 Interfacing with Raspberry Pi using Pi4J - June 19, 2017
- Send data using MQTT from Raspberry Pi with JAVA - June 12, 2017