#include "vision.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define pii pair<int,int>
using namespace std;

vector<int> getVisionPattern1d()
{
    return {1,1,1,2,3};
}

int getMove1d(vector<int> v)
{
	int n=v.size();
	int ind=n/2;
	if (v[ind]==3) {
		if (v[ind+1]==1) return n-1;
		return 0;
	}
	if (v[ind]==2) {
		if (v[ind+1]==3) return ind+1;
		return ind-1;
	}
	if (v[ind]==1) {
		if (v[ind+1]==v[ind-1]) return ind+1;
		if (v[ind+1]!=1) return ind+1;
		return ind-1;
	}
}

vector<vector<int>> getVisionPattern2d()
{
    return {{1,2,3},{4,5,6},{7,8,9}};
}
pair<int, int> getMove2d(vector<vector<int>> v)
{
    int arr[5][5],cnt=1;
    for (int i=1; i<=3; i++) {
    	for (int j=1; j<=3; j++) {
    		arr[i][j]=cnt; cnt++;
		}
	}
    for (int i=1; i<=4; i++) {
    	for (int j=1; j<=4; j++) {
    		if (i==4) {
    			arr[i][j]=arr[i-3][j];
			}
			if (j==4) arr[i][j]=arr[i][j-3];
		}
	}
	
	int n=v.size();
	int ind=n/2;
	
	int val=v[ind][ind];
	int ii=0,jj=0;
	for (int i=1; i<=3; i++) {
		for (int j=1; j<=3; j++) {
			if (arr[i][j]==val) {
				ii=i; jj=j;
			}
		}
	}
	int val2=arr[ii+1][jj+1];
	if (v[ind+1][ind+1]==val2) return {ind+1,ind+1};
	if (v[ind+1][ind-1]==val2) return {ind+1,ind-1};
	if (v[ind-1][ind+1]==val2) return {ind-1,ind+1};
	if (v[ind-1][ind-1]==val2) return {ind-1,ind-1};
}