CS代考程序代写 3/2/2021 Curling Score | Assignment Module 4 | CS 116 Courseware | UW Online

3/2/2021 Curling Score | 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…  Curling Score
Curling Score
Curling is played by two teams throwing rocks towards circles at the end of a sheet of ice. The circles are called the house. The centre of the house is called the button.
The game is split into ends. In each end, a yellow team throws eight yellow rocks and a red team throws eight red rocks. If no rocks end up in the house, then no team scores points for that end. Otherwise, only the team with a rock nishing closest to the button scores points for that end. The number of points they score is the number of their rocks in the house that nish in a position closer to the button than every other rock of the other colour. For simplicity, we will assume that there are no ties in an end. That is, no two rocks will be the same distance to the button. Here are ve examples where some of the rocks not in the house are not pictured:
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 Curling Score | Assignment Module 4 | CS 116 Courseware | UW Online
Credit: http://www.sportmember.pl/en/sports-rules/curling-rules
Points earned in each end are totalled to give a team’s nal score.
Chips embedded in each rock report the distance to the button for the nal position of each rock that nishes in the house. Chips do not report anything for rocks that are not in the house. Specically, the chips give a list of strings where each string consists of exactly the following (in order):
Three digits representing the distance to the button for a rock. Leading zeros are included if necessary so this distance will be between 000 and 999 (inclusive).
“Y” or “R” indicating the colour of the rock (representing yellow and red respectively). The number of the end which is a positive integer between 1 and 99 (inclusive).
For example, the following list could represent the positions of all the rocks in the house in the ve ends shown in the example above.
sample_rock_positions = [“041Y1″,”209R1″,”389Y1″,”596R1”,
“045Y2″,”198R2″,”376R2″,”380R2″,”415R2″,”606R2”,
“043Y3″,”071Y3″,”108R3″,”400Y3″,”402Y3”,
“042Y4″,”075Y4″,”076Y4″,”422R4”]
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 Curling Score | Assignment Module 4 | CS 116 Courseware | UW Online
Unfortunately, this chip technology is very new and there are no guarantees about the order of the strings in a list of rock positions. The list might not be nicely ordered as in the example above.
Write the function:
that returns the score of the team throwing colour (“Y” or “R”) based on rock_positions given by the chip technology as specied above.
Samples:
To earn 90% of the correctness marks, you must use an abstract list function at least once but may also use recursion. To earn full marks, you may not use recursion at all. You might nd it challenging to earn this nal 10%. Give it a try but don’t waste too much time on this!
A few additional notes for the curious:
Most ocial real curling games have 10 ends but our games might have as many as 99 ends.
Dierent real curling rinks use dierent coloured rocks but we are sticking with red and yellow for simplicity.
To the best of our knowledge, the technology of embedding chips in granite rocks to score curling games is pure ction. The rules for scoring are accurate.
No submissions found
1 def score(colour, rock_positions):
score(colour, rock_positions)
score(“Y”, sample_rock_positions) => 7
score(“R”, sample_rock_positions) => 0
score(“R”, [“101R1”, “115R4”, “116R2”, “012R4”, “222R4”]) => 5
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 *