CS代考程序代写 3/2/2021 Snakes and Ladders | Assignment Module 4 | CS 116 Courseware | UW Online

3/2/2021 Snakes and Ladders | Assignment Module 4 | CS 116 Courseware | UW Online

A new course announcement has been posted. Click here to view the new announcement.

The site will be unavailable Mar 2, 2021 from 6:30 AM ET – 7:00 AM ET (Waterloo time) for scheduled maintenance.
Course  Module 4: Lists  Assignment Modul…  Snakes and Ladders
Snakes and Ladders
This question is inspired by the game Snakes and Ladders. The details and rules are not relevant here. However, if you are unfamiliar with the game and interested, you can see Wikipedia to learn about it and its interesting history. If you are familiar with the game, then don’t try to use your knowledge of its rules and set- up to try and impose any unstated restrictions or assumptions on this problem.
Your job is to add snakes and ladders to an empty board. Write the function
that consumes nested lists snakes, ladders and board. The rst two consumed lists are lists of lists of integers. Each integer is the number of a cell in a 10 by 10 board where cells are numbered as shown below:
make_board(snakes, ladders, board)
https://online.cs.uwaterloo.ca/courses/course-v1:UW+CS116+2021_01/courseware/42d9be21ec8244f5a2a251ea657d69e5/9683588d0b2849079f8bfdb1f7f16768/1?activate_block_id=block-v1%3AUW… 1/6

3/2/2021 Snakes and Ladders | Assignment Module 4 | CS 116 Courseware | UW Online
No integer will appear more than once across both the consumed lists. Put another way, [snakes]+[ladders] won’t contain any duplicates.
The parameter board will be a list of list of strings representing an empty 10 by 10 board. That is, the outer list and each inner list will have length 10 and each string will be “.” (a period). To help with your testing, we have provided a function empty_board which produces this value.
Your function must return None and mutate board so that each string in board becomes the letter “S” if the number of the cell appears in snakes
becomes the letter “L” if the number of the cell appears in ladders, or is unchanged otherwise. 59540
Sample:
Suppose the following is executed.
B = empty_board()
make_board([[1,20,21,40],[78,64],[50]],[[99,82,79,62,59],[47,53,69]],B)
100 99 98 97 96 95 94 93 92 91
81 82 83 84 85 86 87 88 89 90
80 79 78 77 76 75 74 73 72 71
61 62 63 64 65 66 67 68 69 70
60 59 58 57 56 55 54 53 52 51
41 42 43 44 45 46 47 48 49 50
40 39 38 37 36 35 34 33 32 31
21 22 23 24 25 26 27 28 29 30
20 19 18 17 16 15 14 13 12 11
1 2 3 4 5 6 7 8 9 10
https://online.cs.uwaterloo.ca/courses/course-v1:UW+CS116+2021_01/courseware/42d9be21ec8244f5a2a251ea657d69e5/9683588d0b2849079f8bfdb1f7f16768/1?activate_block_id=block-v1%3AUW… 2/6

3/2/2021
Snakes and Ladders | Assignment Module 4 | CS 116 Courseware | UW Online
Afterwards, the variable B will be mutated so that it is now equal to:
[[‘.’, ‘L’, ‘.’, ‘.’, ‘.’, ‘.’, ‘.’, ‘.’, ‘.’, ‘.’],
[‘.’, ‘L’, ‘.’, ‘.’, ‘.’, ‘.’, ‘.’, ‘.’, ‘.’, ‘.’],
[‘.’, ‘L’, ‘S’, ‘.’, ‘.’, ‘.’, ‘.’, ‘.’, ‘.’, ‘.’],
[‘.’, ‘L’, ‘.’, ‘S’, ‘.’, ‘.’, ‘.’, ‘.’, ‘L’, ‘.’],
[‘.’, ‘L’, ‘.’, ‘.’, ‘.’, ‘.’, ‘.’, ‘L’, ‘.’, ‘.’],
[‘.’, ‘.’, ‘.’, ‘.’, ‘.’, ‘.’, ‘L’, ‘.’, ‘.’, ‘S’],
[‘S’, ‘.’, ‘.’, ‘.’, ‘.’, ‘.’, ‘.’, ‘.’, ‘.’, ‘.’],
[‘S’, ‘.’, ‘.’, ‘.’, ‘.’, ‘.’, ‘.’, ‘.’, ‘.’, ‘.’],
[‘S’, ‘.’, ‘.’, ‘.’, ‘.’, ‘.’, ‘.’, ‘.’, ‘.’, ‘.’],
[‘S’, ‘.’, ‘.’, ‘.’, ‘.’, ‘.’, ‘.’, ‘.’, ‘.’, ‘.’]]
Note that we have displayed this list value on multiple lines to make it easier to read. Depending on how you look at your own list values, they might not look as pretty.
For this question, you may use recursion and/or abstract list functions (map or filter).
No submissions found
1 ## A Board is a (listof (listof Str))
2 ## Requires:
3 ##
4 ##
5 ##
6
The length of the outer list is 10.
The length of each inner list is 10.
Each string is ‘.’, ‘L’, or ‘S’.
7 def empty_board():
8 ## THIS IS FUNCTION IS PROVIDED TO HELP YOU TEST make_board.
9 ## WE RECOMMEND THAT YOU DON’T CHANGE IT.
10 ”’
11 Returns a list of lists representing a Snakes and Ladders
12 board where each entry is a period.
13
https://online.cs.uwaterloo.ca/courses/course-v1:UW+CS116+2021_01/courseware/42d9be21ec8244f5a2a251ea657d69e5/9683588d0b2849079f8bfdb1f7f16768/1?activate_block_id=block-v1%3AUW… 3/6

Leave a Reply

Your email address will not be published. Required fields are marked *