Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are presented with a two - dimensional grid of size N M ( N rows and M columns ) . EachGiven grid = [

You are presented with a two-dimensional grid of size NM(N rows and M columns). EachGiven grid =["are", "Mes", "MaM"], the function should return 4. Graphical representation of
the second example:
Given grid BBsa", mar, "Bema", \marr], the function shouldreturn 7. Graphical
representation of the third example:
Task 1
Given srid =["esas","Mmm", "Bems", "Mmm"], the function should retum 7. Graphical
representation of the third example:
Write an efficient algorithm for the following assumptions:
. N is an integer within the range [1.250):
all strings in grid are of the same length M from the range [1.250]:
every string in grid consists only of the characters B and/or Wr.
cell in the grid is either black (B) or white (W). A row or column is considered symmetric if it
reads the same forwards as it does backward. For example, a row "BWWBWWB" is symmetric
whereas "WBWB" isn't. The same symmetry criterion applies to columns. In one move, you can
change the color in a single cell to the opposite. Your task is to determine the minimum
number of moves required to make every row and column in the grid symmetric.
Write a function:
def solution(grid)
that, given an array srid consisting of N strings, all of length M(each string is a single row of
the grid), returns the minimum number of moves required to make all rows and columns
symmetric.
Examples:
Given grid =["BBWWB","WWWBW","BWWW"], the function should return 3. In the beginning, the
grid appears as follows:
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Database Programming

Authors: Chris Fehily

1st Edition

1937842312, 978-1937842314

More Books

Students also viewed these Databases questions

Question

What is adaptive integration? Why is it useful?

Answered: 1 week ago

Question

Relational Contexts in Organizations

Answered: 1 week ago