-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy path1053SetMe.cpp
More file actions
50 lines (49 loc) · 1.36 KB
/
1053SetMe.cpp
File metadata and controls
50 lines (49 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
using namespace std;
inline bool same(char c1,char c2,char c3){
return c1==c2 && c1==c3;
}
inline bool diff(char c1,char c2,char c3){
return c1!=c2 && c1!=c3 && c2!=c3;
}
inline bool check(string c1,string c2,string c3){
int good = 0;
for(int i=0;i<4;i++)
if(same(c1[i],c2[i],c3[i]) || diff(c1[i],c2[i],c3[i])) good++;
return good==4;
}
int main()
{
string card;
while(true){
bool has = false;
vector<string> cards;
while(getline(cin,card)){
has = true;
if(card=="")break;
cards.push_back(card);
}
if(!has) break;
cout<<"CARDS: ";
for(int i=0;i<cards.size();i++)
cout<<" "<<cards[i];
cout<<endl;
cout<<"SETS: ";
int cnt = 0;
for(int i=0;i<cards.size();i++)
for(int j=i+1;j<cards.size();j++)
for(int k=j+1;k<cards.size();k++){
if(check(cards[i],cards[j],cards[k])){
cnt++;
if(cnt>1)printf(" ");
printf("%d. %s %s %s\n",cnt,cards[i].c_str(),cards[j].c_str(),cards[k].c_str());
}
}
if(!cnt) printf("*** None Found ***\n");
printf("\n");
}
return 0;
}