You and your neighbor have equal sized gardens. Your gardens are represented as 2D-lists, where garden[i] [j] gives an element at position (i, j). Every element in a garden is represented as an string, and can be "grass", "moss", "strawberry" , "rock", "raspberry". Latley you have noticed more moss and rock in your garden and espects its to be your neighbor. To fix it, complete the function  clean_mygarden(my_garden, neighbors_garden) At the end , swap every rock and moss in your garden with the first stawberry and raspberry from neighbor (they dont need to be at the same position MAKE A FUNCTION "find_items" that inputs two arguments: (garden, item) , and returns a (i, j) position as a tuple if item is in garden. If not, return None.  Make a function swap_items that swaps two elements between two gardens. Let the function Input these arguments (garden1, garden2, pos1, pos2), where pos1 and pos2 is (i,j) tuples. def swap_items(garden1,garden2,pos1,pos2): Here you are not going to return something but change the lists you get as arguments.  Use the functions you already defined to finish clean_garden(my_garden, neighbors_garden): Swap all rocks with strawberry and moss with raspberry from your neighbors garden as long as its possible to swap.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Python

 

You and your neighbor have equal sized gardens. Your gardens are represented as 2D-lists, where garden[i] [j] gives an element at position (i, j). Every element in a garden is represented as an string, and can be "grass", "moss", "strawberry" , "rock", "raspberry". Latley you have noticed more moss and rock in your garden and espects its to be your neighbor. To fix it, complete the function  clean_mygarden(my_garden, neighbors_garden)

At the end , swap every rock and moss in your garden with the first stawberry and raspberry from neighbor (they dont need to be at the same position

MAKE A FUNCTION "find_items" that inputs two arguments: (garden, item) , and returns a (i, j) position as a tuple if item is in garden. If not, return None. 

Make a function swap_items that swaps two elements between two gardens. Let the function Input these arguments (garden1, garden2, pos1, pos2), where pos1 and pos2 is (i,j) tuples.
def swap_items(garden1,garden2,pos1,pos2):
Here you are not going to return something but change the lists you get as arguments. 

Use the functions you already defined to finish clean_garden(my_garden, neighbors_garden):
Swap all rocks with strawberry and moss with raspberry from your neighbors garden as long as its possible to swap. 

 

 

 

def find_item(garden,item):
# your code
return None
def swap_items(garden1,garden2, pos1, pos2):
# your code
pass
def clean_garden (my_garden, neighbors_garden):
# your code
pass
if
name
main
":
==
my_garden = [
["grass", "moss"],
["moss", "strawberry"],
["moss",
,"rock"]
other_garden = [
["grass", "raspberry"],
["grass", "strawberry"],
["strawberry","rock"]
clean_garden(my_garden, other_garden)
my_after = [
['grass', 'raspberry'],
['moss', 'strawberry'],
['moss', 'strawberry']
other_after = [
['grass', 'moss'],
['grass', 'rock'],
['strawberry', 'rock']
if my_after == my_garden and other_after ==
print('OK!')
other_garden:
Transcribed Image Text:def find_item(garden,item): # your code return None def swap_items(garden1,garden2, pos1, pos2): # your code pass def clean_garden (my_garden, neighbors_garden): # your code pass if name main ": == my_garden = [ ["grass", "moss"], ["moss", "strawberry"], ["moss", ,"rock"] other_garden = [ ["grass", "raspberry"], ["grass", "strawberry"], ["strawberry","rock"] clean_garden(my_garden, other_garden) my_after = [ ['grass', 'raspberry'], ['moss', 'strawberry'], ['moss', 'strawberry'] other_after = [ ['grass', 'moss'], ['grass', 'rock'], ['strawberry', 'rock'] if my_after == my_garden and other_after == print('OK!') other_garden:
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Knowledge Booster
Lists
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education