-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSmartGuesser.cpp
More file actions
49 lines (47 loc) · 1.12 KB
/
SmartGuesser.cpp
File metadata and controls
49 lines (47 loc) · 1.12 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
#include <iostream>
#include "SmartGuesser.hpp"
using namespace std;
using namespace bullpgia;
string SmartGuesser::guess(){
string curr = "";
if(this->firstGuess){
for(int i=0; i<this->length; i++){
curr += '0';
}
this->bull = -1;
this->index = 0;
this->prev = curr;
this->firstGuess = false;
return curr;
}
int bulltemp = this->last.at(0) - '0';
curr = this->prev;
if(this->bull == -1){
this->bull = bulltemp;
curr.at(this->index)++;
this->prev = curr;
return curr;
}
else{
if(this->bull == bulltemp){
curr.at(index)++;
this->prev = curr;
return curr;
}
if(this->bull > bulltemp){
curr.at(index)--;
index++;
curr.at(index)++;
this->prev = curr;
return curr;
}
if(bull < bulltemp){
index++;
curr.at(index)++;
this->bull = bulltemp;
this->prev = curr;
return curr;
}
}
return curr;
}