#include #include #include #include #include using namespace std; int getCost(const vector& rhs, const vector& lhs) { int cost = 0; for( int i=0; i<9; i++ ) cost += abs(rhs[i]-lhs[i]); //cout << cost << " - cost" << endl; return cost; } int main() { vector> possiblesolutions; vector input; int min=0; possiblesolutions.push_back({2, 7, 6, 9, 5, 1, 4, 3, 8}); possiblesolutions.push_back({2, 9, 4, 7, 5, 3, 6, 1, 8}); possiblesolutions.push_back({6, 1, 8, 7, 5, 3, 2, 9, 4}); possiblesolutions.push_back({6, 7, 2, 1, 5, 9, 8, 3, 4}); possiblesolutions.push_back({8, 1, 6, 3, 5, 7, 4, 9, 2}); possiblesolutions.push_back({8, 3, 4, 1, 5, 9, 6, 7, 2}); possiblesolutions.push_back({4, 3, 8, 9, 5, 1, 2, 7, 6}); possiblesolutions.push_back({4, 9, 2, 3, 5, 7, 8, 1, 6}); for( int i=0; i<9; i++ ) { int inp; cin >> inp; input.push_back(inp); } for( size_t t=0; t cost ) min = cost; } cout << min; return 0; }