Crack the crag def crag_score(dice): Crag (see the Wikipedia page for the scoring table needed in this problem) is a dice game similar to the more popular games of Yahtzee and Poker dice in style and spirit, but with much simpler combinatorics of roll value calculation due to this game using only three dice. Players repeatedly roll three dice and assign the resulting patterns to scoring categories so that once some roll has been assigned to a category, that category is considered to have been spent and cannot be used again for any future roll. These tactical choices between safety and risk-taking give this game a little bit more tactical flair on top of merely relying on the favours of Lady Luck for rolling the bones.   Given the list of pips of the three dice of the first roll, this function should compute and return the highest possible score available when all categories of the scoring table are still available for you to choose from, so that all that matters is maximizing this first roll. Note that the examples on the Wikipedia page show the score that some dice would score in that particular category, which is not necessarily even close to the maximum score in principle attainable with that roll. For example, the roll [1, 1, 1] inefficiently used in the category “Ones” would indeed score only three points, whereas that same roll would score a whopping 25 points in the more fitting category “Three of a kind”. (The problem “Optimal crag score” later in this collection has you distribute these rolls into distinct categories to maximize the total score.)   This problem ought to be a straightforward exercise on if-else ladders combined with simple sequence management. Your function should be swift and sure to return the correct answer for every one of the 63 = 216 possible pip combinations. However, you will surely design your if-else structures to handle entire equivalence classes of pip combinations in a single step, so that your entire ladder consists of far fewer than 216 separate steps...

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

Crack the crag
def crag_score(dice):

Crag (see the Wikipedia page for the scoring table needed in this problem) is a dice game similar to the more popular games of Yahtzee and Poker dice in style and spirit, but with much simpler combinatorics of roll value calculation due to this game using only three dice. Players repeatedly roll
three dice and assign the resulting patterns to scoring categories so that once some roll has been assigned to a category, that category is considered to have been spent and cannot be used again for
any future roll. These tactical choices between safety and risk-taking give this game a little bit more tactical flair on top of merely relying on the favours of Lady Luck for rolling the bones.

 

Given the list of pips of the three dice of the first roll, this function should compute and return the highest possible score available when all categories of the scoring table are still available for you to choose from, so that all that matters is maximizing this first roll. Note that the examples on
the Wikipedia page show the score that some dice would score in that particular category, which is not necessarily even close to the maximum score in principle attainable with that roll. For example, the roll [1, 1, 1] inefficiently used in the category “Ones” would indeed score only
three points, whereas that same roll would score a whopping 25 points in the more fitting category “Three of a kind”. (The problem “Optimal crag score” later in this collection has you distribute these rolls into distinct categories to maximize the total score.)

 

This problem ought to be a straightforward exercise on if-else ladders combined with simple sequence management. Your function should be swift and sure to return the correct answer for every one of the 63 = 216 possible pip combinations. However, you will surely design your if-else
structures to handle entire equivalence classes of pip combinations in a single step, so that your entire ladder consists of far fewer than 216 separate steps...

dice
Expected result
[1, 2, 3]
20
[4, 5, 1]
5
[3, 3, 3]
25
[4, 5, 4]
50
[1, 1, 1]
25
[1, 1, 2]
2
Transcribed Image Text:dice Expected result [1, 2, 3] 20 [4, 5, 1] 5 [3, 3, 3] 25 [4, 5, 4] 50 [1, 1, 1] 25 [1, 1, 2] 2
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Random Class and its operations
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.
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