#include <bits/stdc++.h>
#include "vision.h"

using namespace std;

vector<int> getVisionPattern1d()
{
    return {1,2,1,3,1};
}
int getMove1d(vector<int> v)
{
    int n=v.size(),put,mijl;
    vector<int> poz[20];
    for(int i=0;i<v.size();i++)
        poz[v[i]].push_back(i);
    mijl=(v.size()-1)/2;
    put=v[mijl];
    if(put==1)
    {
        if(v[mijl+1]+v[mijl-1]==5)
        {
            if(v[mijl+1]==3)
                return mijl+1;
            return mijl-1;
        }
        else if(v[mijl+1]==3 || v[mijl-1]==3)
        {
            if(v[mijl-1]==3)
                return mijl+1;
            return mijl-1;
        }
        else if(v[mijl+1]==2 || v[mijl-1]==2)
        {
            if(v[mijl+1]==2)
                return mijl+1;
            return mijl-1;
        }
    }
    if(put==2)
    {
        if(v[mijl+2]==3)
            return mijl+2;
        return mijl-2;
    }
    if(put==3)
    {
        if(v[mijl-2]==2)
            return mijl+3;
        return mijl-3;
    }
}
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
vector<vector<int>> getVisionPattern2d()
{
    return {{1,2,3},{2,3,1},{3,1,2}};
}
pair<int,int> getMove2d(vector<vector<int>> v)
{
    int mijl=(v.size()-1)/2,put,target,i,xn,yn;
    put=v[mijl][mijl];
    if(put==2)
        target=3;
    if(put==1)
        target=2;
    if(put==3)
        target=1;
    for(i=0;i<4;i++)
    {
        xn=mijl+dx[i];
        yn=mijl+dy[i];
        if(v[xn][yn]==target)
            return {xn,yn};
    }
}
