Skip to content

Commit 61a41b9

Browse files
authored
Create 37_codechef_spell_bob.cpp
1 parent 0f9ed93 commit 61a41b9

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

37_codechef_spell_bob.cpp

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
//
2+
// main.cpp
3+
// Lecture 37
4+
//
5+
// Created by Prince Kumar on 17/04/19.
6+
// Copyright © 2019 Prince Kumar. All rights reserved.
7+
//
8+
// CODE-CHEF
9+
10+
// --- ** Problems on Spell bob ** --- //
11+
12+
13+
#include <iostream>
14+
using namespace std;
15+
int main()
16+
{
17+
int T; cin>>T;
18+
while(T--)
19+
{
20+
string s1,s2; cin>>s1>>s2;
21+
int a[3]={0}; // b count
22+
for(int i=0;i<3;i++) // 'b' present or not
23+
{
24+
if(s1[i]=='b' || s2[i]=='b')
25+
a[i]=1;
26+
}
27+
int b_count=0;
28+
for(int i=0;i<3;i++)
29+
{
30+
if(a[i]==1)
31+
b_count++;
32+
}
33+
if(b_count<=1)
34+
cout<<"no"<<endl;
35+
else if(b_count==2)
36+
{
37+
int index=0;
38+
for(int i=0;i<3;i++)
39+
{
40+
if(a[i]==0)
41+
index=i;
42+
}
43+
if(s1[index]=='o' || s2[index]=='o')
44+
cout<<"yes"<<endl;
45+
else
46+
cout<<"no"<<endl;
47+
}
48+
else if(b_count==3)
49+
{
50+
int o_count=0;
51+
for(int i=0;i<3;i++)
52+
{
53+
if(s1[i]=='o' || s2[i]=='o')
54+
o_count++;
55+
}
56+
if(o_count==0)
57+
cout<<"no"<<endl;
58+
else
59+
cout<<"yes"<<endl;
60+
}
61+
}
62+
}
63+
64+

0 commit comments

Comments
 (0)