1. def make_grid(w: int, h: int, player_coord: Tuple[int, int],
gold_coord: Tuple[int, int]) -> List[List[str]]:
"""
Given two integers width w and height h, create a list
of lists to represent a grid of the given width and height.
The coordinates for the player and the gold
is also given as two two-element tuples. For each tuple,
the first element has the x-coordinate and the
second element has the y-coordinate. The player
and the gold should be included in the grid in
the positions specified by these tuples.
The player is represented with the string '(x)'
The gold is represented with the string '(o)'
All other spaces are represented with the string '(_)'
Return this list.
>>> make_grid(2, 3, (0, 0), (1, 2))
[['(x)', '(_)'], ['(_)','(_)'], ['(_)', '(o)']]
"""
2. def update_grid(grid: List[List[str]], w: int, h: int, px: int, py: int,
dx: int, dy: int) -> Optional[Tuple[int, int]]:
"""
Given the player's current position as px and py,
and the directional changes in dx
and dy, update the given grid to change the player's
x-coordinate by dx, and their y-coordinate by dy.
More information:
Use the given w and h (representing the grid's width
and height) to figure out whether or not the move is valid.
If the move is not valid (that is, if it is outside
of the grid's boundaries), then NO change occurs to the grid.
The grid stays the same, and nothing is returned.
If the move IS possible, then the grid is updated
by adding dx to the player's x-coordinate,
and adding dy to the player's y-coordinate.
The new position in the grid is changed to the player
icon '(x)', and the old position the player used to be in
is changed to an empty space '(_)'. The new x- and y- coordinates
of the player is returned as a tuple.
This function does NOT create or return a new grid.
It modifies the "grid" list that is passed into it directly.
>>> L = [['(x)', '(_)'], ['(_)', '(o)'], ['(_)', '(_)']]
>>> update_grid(L, 2, 3, 0, 0, 1, 0)
(1, 0)
>>> L
[['(_)', '(x)'], ['(_)', '(o)'], ['(_)', '(_)']]
>>> L = [['(x)', '(_)'], ['(_)', '(o)'], ['(_)', '(_)']]
>>> update_grid(L, 2, 3, 0, 0, 0, 1)
(0, 1)
>>> L
[['(_)', '(_)'], ['(x)', '(o)'], ['(_)', '(_)']]
>>> L = [['(x)', '(_)'], ['(_)', '(o)'], ['(_)', '(_)']]
>>> print(update_grid(L, 2, 3, 0, 0, -1, 0))
None
>>> L
[['(x)', '(_)'], ['(_)', '(o)'], ['(_)', '(_)']]
"""
3. Add some sort of scoring
Step by stepSolved in 2 steps with 1 images
- def print_categories(main_list): for i in all_categories: main_list = all_categories.split() print(i,":",all_categories[i]) return "" """ Given a list of lists, for each list stored in main_list, output its contents as follows: f"{index of category}. {item[0]} - {item[1]}%". note that indexing must start at 1 for the first item, not 0, which is first item's actual index in main_list. If `main_list` is empty, the function prints "There are no categories." Returns the number of categories.arrow_forwardstruct insert_at_back_of_sll { // Function takes a constant Book as a parameter, inserts that book at the // back of a singly linked list, and returns nothing. void operator()(const Book& book) { /// TO-DO (3) /// // Write the lines of code to insert "book" at the back of "my_sll". Since // the SLL has no size() function and no tail pointer, you must walk the // list looking for the last node. // // HINT: Do not attempt to insert after "my_sll.end()". // ///// END-T0-DO (3) ||||// } std::forward_list& my_sll; };arrow_forwardAlert dont submit AI generated answer. please explain in details. Please print fixlist function so it would print out both lists a = [1, 5, 3, 6] b = [3, 5, 3 ,2, 4, 6, 8, 5, 2] def printList(list): for i in range(9): print(list[i]) print("End of List" print list(a) printList(b) Expected output: 1 5 3 6 End of List 3 5 3 2 4 6 8 5 2arrow_forward
- Here is the code for number 1. def reverse_list(old_list): new_list = [ele for ele in reversed(old_list)] return new_list if __name__ == "__main__": str = input("Enter the elements of the list: ").split() elements = list(map(int, str)) print(reverse_list(elements))arrow_forwardlst1= [4,3,2,6,2] and lst2=[1,2,4] then the new_list is [2,2,4]. Assign the new-list to variable new_list and sort. Code: What is wrong with this code? lst1= [4,3,2,6,2] lst2=[1,2,4] new_list=[] for elements1 in lst1: for elements2 in lst2: elements1==elements2: new_list.append(elements1) new_list.sort()arrow_forward4 ete t of With the following lists: list1 = [x + y for x in ['a', 'b', 'c'] for y in ['1', '2', '3']] list2 = [[x + y for x in ['a', 'b', 'c']] for y in ['1', '2', '3']] which option is true? Select one: A. len(list1)> len(list2) B. 'a1' is an element (or subelement) for list1 whereas '1a' is for list2 C. list1 and list2 will error because numbers and letters cannot be added. D. Both A and B are true.arrow_forward
- What does the following error message normally mean? IndexError: list index out of range Select one: а. This error normally indicates that you have tried to access an element of a list that doesn't exist. O b. This error normally means that you have used the range() function incorrectly. С. This error normally means that you have used a list where you should have used a tuple. d. This error normally means that you used too many lines of code in your program.arrow_forwardIn DrRacket, which of the following is the signature of primitive append? A) List List -> ListOfList B) List List -> List C) ListOfList -> ListOfList D) List List ... List -> ListOfList E) List List ... List -> Listarrow_forwarddef large_matrix(matrix: list[list[int]]) -> int:"""Returns the area of the rectangle in the area of a rectangle is defined by number of 1's that it contains.The matrix will only contain the integers 1 and 0.>>> case = [[1, 0, 1, 0, 0],... [1, 0, 1, 1, 1],... [1, 1, 1, 1, 1],... [1, 0, 0, 1, 0]]>>> largest_in_matrix(case1)6"" You must use this helper code: def large_position(matrix: list[list[int]], row: int, col: int) -> int: a = rowb = colmax = 0temp = 0rows = len(matrix)column = len(matrix[a])while a < rows and matrix[a][col] == 1:temp = 0while b < column and matrix[a][b] == 1:temp = temp + 1b = b + 1column = ba = a + 1if (a != row+1):temp2 = temp * (a - row)else:temp2 = tempif max < temp2:max = temp2b = colreturn max """ remember: Please do this on python you should not use any of the following: dictionaries or dictionary methods try-except break and continue statements recursion map / filter import""'arrow_forward
- Stuck on thisarrow_forwardAnybody??arrow_forward3. Write the remove_evens() function that receives a list of integers as a parameter and returns a new list of integers containing only the odd numbers from the original list. Ex1) If n = [1, 2, 3, 4, 5, 6], remove_evens(n) returns [1, 3, 5]. Ex2) If n = [2, 4, 8], remov move_evens(n) returns [].arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY