Use the programming language python to solve the following task You and your neighbor both have equally sized gardens. The gardens are represented as 2D lists, where the garden [i] [j], gives an element to the position (i, j). Each element of a garden is represented as a string, and can be any of the following: "grass", "moss", "strawberry", "rock", "raspberry". You have recently seen that there has been a lot of moss and stone in your garden, and suspect that it is your neighbor who has put it there. To fix this, complete the clean_garden (my_garden, neighbors_garden) function. Here you will first create small functions to make it easier to solve the actual task. Create a function find_item that takes in two arguments: (garden, item), which returns an (i, j) position as a tuple, whose item is in the garden. If it does not exist, return None Create a function swap_items that exchanges two elements between two gardens, let it take in these arguments: (garden1, garden2, pos1, pos2), where pos1 and pos2 are (i, j) doubles. Here you should not return anything, but change the lists you receive as arguments. Use the functions you have defined to complete clean_garden (my_garden, neighbors_garden): Replace all "rock" with "strawberry", and "moss" with "raspberry" from your neighbor's garden as long as there are opportunities for exchange.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Use the programming language python to solve the following task

You and your neighbor both have equally sized gardens. The gardens are represented as 2D lists, where the garden [i] [j], gives an element to the position (i, j). Each element of a garden is represented as a string, and can be any of the following: "grass", "moss", "strawberry", "rock", "raspberry". You have recently seen that there has been a lot of moss and stone in your garden, and suspect that it is your neighbor who has put it there. To fix this, complete the clean_garden (my_garden, neighbors_garden) function. Here you will first create small functions to make it easier to solve the actual task.

Create a function find_item that takes in two arguments: (garden, item), which returns an (i, j) position as a tuple, whose item is in the garden. If it does not exist, return None

Create a function swap_items that exchanges two elements between two gardens, let it take in these arguments: (garden1, garden2, pos1, pos2), where pos1 and pos2 are (i, j) doubles. Here you should not return anything, but change the lists you receive as arguments.

Use the functions you have defined to complete clean_garden (my_garden, neighbors_garden): Replace all "rock" with "strawberry", and "moss" with "raspberry" from your neighbor's garden as long as there are opportunities for exchange.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 4 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY