Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in python3, complete numberOfWalls(board) 10. Number of lego walls You are given a NM board containing O's and X's. An o denotes empty space while

in python3, complete numberOfWalls(board)
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
10. Number of lego walls You are given a NM board containing O's and X's. An o denotes empty space while an X denotes that a lego block is placed at that location Two lego blocks are connected if they share an edge (must be adjacent horizontally or vertically, diagonals don't count). A group of connected lego blocks which cannot be further extended by including any other connected lego block is called a lego wall. Return the number of lego walls on the board Function description You have to complete the function number ofwalls. The input contains: -board: a list of strings, each of which contains X's or O's from one row of the board Return a single integer denoting the number of lego walls on the board. Examples Example 1: xxo0oxo This has the following 3 lego walls: (1) XX (11) (15) Function description You have to complete the function number ofwalls. The input contains: - board: a list of strings, each of which contains X's or O's from one row of the board Return a single integer denoting the number of lego walls on the board. Examples Example 1: XXOOOXO OXOOOXO This has the following 3 lego walls: (1) X XX (111) Example 2: XOXOXX has 4 lego walls: Th (1) X (111) X X Example 2: XOXOXX XOOXOO This has 4 lego walls: (11) (iii) (iv) x x Custom test case format In the first line, enter the number of rows, N, in the board. In each of the N followi lines, enter one string containing one row of the board. Example 2 can be written as: 2 XOXOXX XOOXOO name -10 Complete the number ofwalls function below. def numberOfWalls (board): if __main__': 13 fptr = open(os.environ['OUTPUT_PATH' ], 'w 14 15 board_count = int(input().strip) 16 17 board = [] 18 19 for in range (board_count): 20 board_item = input() 21 board.append(board_item) 22 23 res = numberOfwalls (board) 24 25 fptr.write(str(res) + ' ') 26 27 fptr.close() 28

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

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions

Question

Solve the integral:

Answered: 1 week ago

Question

What is meant by Non-programmed decision?

Answered: 1 week ago

Question

What are the different techniques used in decision making?

Answered: 1 week ago

Question

2 What are the implications for logistics strategy?

Answered: 1 week ago