#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
int main(){
cout<<"The rules of the game: eight colors (red, orange, yellow, green, blue, purple, black, white) take out four random permutations, at the beginning, there will be a random state, R for the position and color are correct, H for the color is correct and the position is wrong, W is the position and color are wrong, you have to make the random color arrangement correct, if all right, the challenge is successful!Good luck!\n";
string s[]={"red","orange","yellow","green","blue","purple","black","white"},s1[5]={},s2[5]={},t1;
int n,cnt,t;
srand(static_cast<unsigned int>(time(0)));
bool flag[8]={};
cnt=1;
t=sizeof(s)/sizeof(s[0]);
while(cnt<5){
n=rand()%t;
if(!flag[n]){
s1[cnt]=s[n];
flag[n]=true;
cnt++;
}
}
memset(flag,0,sizeof(flag));
cnt=1;
while(cnt<5){
n=rand()%t;
if(!flag[n]){
s2[cnt]=s[n];
flag[n]=true;
cnt++;
}
}
printf("%s %s %s %s\n",s2[1].c_str(),s2[2].c_str(),s2[3].c_str(),s2[4].c_str());
for(int i=1;i<5;i++){
t1="";
bool f=false;
for(int j=1;j<5;j++){
if(s1[j]==s2[i]){
if(i==j){
cout<<"R";
t1+='R';
}
else{
cout<<"H";
t1+='H';
}
f=true;
break;
}
}
if(!f){
cout<<"W";
t1+='W';
}
}
if(t1=="RRRR"){
cout<<"\nYou win!";
return 0;
}
while(true){
cin>>s2[1]>>s2[2]>>s2[3]>>s2[4];
t1="";
for(int i=1;i<5;i++){
bool f=false;
for(int j=1;j<5;j++){
if(s1[i]==s2[j]){
if(i==j){
cout<<"R";
t1+='R';
}
else{
cout<<"H";
t1+='H';
}
f=true;
break;
}
}
if(!f){
cout<<"W";
t1+='W';
}
}
if(t1=="RRRR"){
cout<<"\nYou win!";
return 0;
}
}
return 0;
}