Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need someone to convert from C++ to Python. Here is the two files I need conve

ID: 640820 • Letter: I

Question

I need someone to convert from C++ to Python. Here is the two files I need converted:

#include
#include "Queens.h"
#define N 1
#define TEST_PIECE Amazon
using namespace std;

Piece **pieces;
int solutions = 0;

//attempt to place the ith Piece after the Piece at x,y
bool place(int i, int n, int x, int y)
{
if(i==n)
return true;
int k=y;
for(int j=x; j {
for(; k {
//set the ith piece at j,k
pieces[i]->place(j,k);
int l;
//see if piece conflicts with other pieces
for(l=0; l if(pieces[l]->menaces(pieces[i]))
break;
if(l==i)
if(place(i+1,n,j,k))
solutions++;
}
k=0;
}
  
return false;
}


int main()
{
pieces = new Piece*[N];
for(int i=0; i pieces[i] = new TEST_PIECE;
  
place(0,N,0,0);
cout<<"Number of Solutions: "<   
return 0;
}

--------------------------------------------------------------------------------------------------------------------------------------------------------------

#ifndef Queens_Queens_h
#define Queens_Queens_h
#include

class Piece
{
public:
int row() const {return _row;}
int column() const {return _column;}
void place(int row, int col);
virtual bool menaces(const Piece *p) const = 0;
  
protected:
int _row;
int _column;
};

void Piece::place(int row, int col)
{
_row = row;
_column = col;
}

class Rook : public Piece
{
public:
virtual bool menaces(const Piece *p) const
{
return(_row == p->row() || _column == p->column());
}
};

class Queen : virtual public Rook
{
public:
virtual bool menaces(const Piece *p) const
{
//check Rook's moves then diagonals
return Rook::menaces(p) || (abs( _row - p->row() ) == abs( _column - p->column() ));
}
};

class Amazon : virtual public Queen
{
public:
virtual bool menaces(const Piece *p) const;
};

bool Amazon::menaces(const Piece *p) const
{
//check Queen's moves
if(Queen::menaces(p))
return true;
//check knight's moves
if( (abs( _row - p->row() ) == 2) && (abs( _column - p->column() ) == 1) )
return true;
if( (abs( _row - p->row() ) == 1) && (abs( _column - p->column() ) == 2) )
return true;
return false;
}

#endif

Explanation / Answer

The boost.python library is powerful, sometimes subtle, and, when
interacting with python objects, tries to make it possible to write
C++ that