#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
std::string guess_sequence(int N) {
std::string s = "";
string ref = "ABXY";
int n = N;
// brute force first char
for(int i = 0; i < ref.size(); i++){
int coin = press(s + ref[i]);
if(coin == 1){ s += ref[i];
break; }
}
if(s.size() == 0) s += 'Y';
// only need to guess three other chars
string p = "";
for(auto e : ref) if(e != s[0]) p += e;
for(int i = 1; i < n - 1; i++){
string guess = s + p[0] + s + p[1] + p[0] + s + p[1] + p[1] + s + p[1] + p[2];
int gain = press(guess) - i;
if(gain == 2){
s += p[1];
}
if(gain == 1){
s += p[0];
}
if(gain == 0){
s += p[2];
}
}
for(int i = 0; i < p.size(); i++){
int coin = press(s + p[i]);
if(coin == n){ s += p[i];
break; }
}
return s;
}