#include <bits/stdc++.h>

using namespace std;

const int maxn = 203; const int maxstr = 1003;

int n, ted[maxn], tec; char g[maxstr], sq[maxn][maxstr], sa[maxn][maxstr];

void setcol(int c) { printf("\33[%dm", c); }

void init() { FILE* ipf(fopen(“bstk.txt”, “r”)); n = 0; while (fgets(g, sizeof(g), ipf), !feof(ipf)) { char* p; p = strstr(g, “—”); if (!p) continue; *p = 0; strcpy(sq[n], g); strcpy(sa[n], p + strlen("—")); ++ n; } fclose(ipf); printf("%d problems loaded\n", n); }

bool anscmp(char* a, char* b) { for (; *a && *b; ++ a, ++ b) { if (islower(*a)) *a -= 32; if (islower(*b)) *b -= 32; if (*b == 10) break; else if (*a != *b) return 1; } return 0; }

int main() { init(); srand(time(0)); int cc(0), ct(0); memset(ted, 0, sizeof(ted)); tec = 0; while (1) { int x; do { x = rand() % n; } while (ted[x] > tec / n); ++ ted[x], ++ tec; char gs[maxstr]; setcol(34); puts(sq[x]); setcol(37); fgets(gs, sizeof(gs), stdin); setcol(32); fprintf(stdout, sa[x]); if (!anscmp(gs, sa[x])) { ++ cc; } ++ ct; fprintf(stderr, “\33[31m%d/\33[35m%d\n”, cc, ct); } }