Question: Write a method copy(self) that returns a newly-constructed Board object that is a deep copy of the called object (i.e., of the object represented by

Write a method copy(self) that returns a newly-constructed Board object that is a deep copy of the called object (i.e., of the object represented by self).

This method should use the Board constructor to create a new Board object with the same configuration of tiles as self, and it should return the newly created Board object.

Hint: The Board constructor takes a string of digits. How could you easily obtain the appropriate string of digits for the called Board?

Examples:

>>> b = Board('142358607') >>> b 1 4 2 3 5 8 6 _ 7 >>> b2 = b.copy() >>> b2 1 4 2 3 5 8 6 _ 7 >>> b2.move_blank('up') True >>> b2 1 4 2 3 _ 8 6 5 7 >>> b # the original Board is unchanged 1 4 2 3 5 8 6 _ 7

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!