daisy-and-the-transformation

Mack gives Daisy two strings S1 and S2-consisting only of characters- 'M' and 'D' , and asks her to convert S1 to S2 in exactly N moves.

In a single move, Daisy has two choices:
Exchange any one 'M' with a 'D', or
Exchange any one 'D' with a 'M'.

You need to help Daisy if it's possible to transform S1 to S2 in exactly N moves. Output "Yes" if possible, else "No".

Input Format:
First line contains T, the number of test cases. T lines follow.
Each line consists of 2 space separated strings S1 and S2, and and the value N.

Output Format:
For each test case, print the answer, either "Yes" or "No"-(Without the quotes).

Constraints:
1 ≤ T ≤ 250
1 ≤ |S1|=|S2| ≤ 50
1 ≤ N ≤ 100

SAMPLE INPUT
3
MMDMDDM DDDDDDD 2
MMDD MMDD 1
MMMMMDMM DDDDDMDD 8

SAMPLE OUTPUT
No
No
Yes

Source: hackerearth | Difficulty: EASY
Tags: String algorithms

Ad-hoc


Solutions:
t = int(input())
while t:
	t=t-1
	s1,s2,n = input().split()
	n = int(n)
	cnt = 0;
	for i in range(len(s1)):
		if s1[i] != s2[i]:
			cnt+=1
	if cnt<=n and (n-cnt)%2==0:
		print("Yes")
	else:
		print("No")
			


t=eval(input())
while(t):
	s1,s2,s3=list(map(str,input().split()))
	n=int(s3)
	c=0
	for i in range(len(s1)):
		if s1[i]!=s2[i]:
			c+=1;
	c=n-c
	if c<0 or c%2:
		print("No")
	else:
		print("Yes")
	t=t-1


t=int(input())
while(t>0):
	t=t-1
	x,y,n=input().split();
	k=int(n)
	c=0
	for i in range(len(x)):
		if(x[i]!=y[i]):
			c = c + 1
	if(c==k or (c<k and (k-c)%2==0)):
		print("Yes")
	else:
		print("No")


for _ in range(eval(input())):
	a,b,n=list(map(str,input().split()))
	count=0
	i=0
	l=len(a)
	n=int(n)
	while i <l:
		if a[i]!=b[i]:
			count+=1
		i=i+1
	if n>=count and (n-count)&1==0:
		print('Yes')
	else:
		print("No")
		


for i in range(eval(input())):
	orig, repl, step = input().split()
	size , step,count = len(orig), int(step), 0
	for j in range(size):
		if orig[j] != repl[j]:
			count += 1
	
	if count >step:
		print("No")
	elif count == step or (step - count) %2 ==0:
		print("Yes")
	else:
		print("No")


n = int(input().strip())

for i in range(0, n):
	s=[]
	s = (input().strip()).split()
	count = 0

	for j in range(0, len(s[0])):
		if s[0][j] != s[1][j]:
			count +=1
		else:
			continue

	#print count
	if count <= int(s[2]) and (int(s[2]) - count)%2 == 0:
		print("Yes")
	else:
		print("No")