#Imagine we're writing some code for a video game. #In this video game, there are six elements, which #come in three pairs: Fire and Ice; Land and Water; #Time and Space. Each pair of elements cancels #themselves out: if an attack does 3 Fire damage and #3 Ice damage, then it does 0 total damage. # #Write a function called calculate_damage. #calculate_damage should take as input a list of #2-tuples. The first item of each 2-tuple will be an #integer; the second will be a string, either "Fire", #"Ice", "Land", "Water", "Time", or "Space". 1 #Your function should return a list of three 2-tuples: #the first will represent the total Fire or Ice #damage, such as (3, "Ice") or (2, "Fire"). The #second will represent the total Land or Water damage, #such as (3, "Water") or (2, "Land"). The third #will represent the total Time or Space damage, #such as (3, "Time") or (2, "Space"). # #You may assume that there will always be some net #damage for each of the three categories (e.g. you #don't have to handle the case where there is 0 Fire #or Ice damage). #For example, for the following list of 2-tuples... # # attacks = [(3, # (2, "Fire"), (2, "Ice"), (5, "Water"), "Land"), (1, "Time"), (2, "Space")] # calculate_damage (attacks) -> [(1, "Fire"), (3, "Water"), (1, "Space")] # #Because: #3 Fire 2 ce 1 Fire #5 Water + 2 Land = 3 Water #1 Time + 2 Space = 1 Space # #HINT: For each of the three pairs, try thinking of #one as positive and the other as negative.
#Imagine we're writing some code for a video game. #In this video game, there are six elements, which #come in three pairs: Fire and Ice; Land and Water; #Time and Space. Each pair of elements cancels #themselves out: if an attack does 3 Fire damage and #3 Ice damage, then it does 0 total damage. # #Write a function called calculate_damage. #calculate_damage should take as input a list of #2-tuples. The first item of each 2-tuple will be an #integer; the second will be a string, either "Fire", #"Ice", "Land", "Water", "Time", or "Space". 1 #Your function should return a list of three 2-tuples: #the first will represent the total Fire or Ice #damage, such as (3, "Ice") or (2, "Fire"). The #second will represent the total Land or Water damage, #such as (3, "Water") or (2, "Land"). The third #will represent the total Time or Space damage, #such as (3, "Time") or (2, "Space"). # #You may assume that there will always be some net #damage for each of the three categories (e.g. you #don't have to handle the case where there is 0 Fire #or Ice damage). #For example, for the following list of 2-tuples... # # attacks = [(3, # (2, "Fire"), (2, "Ice"), (5, "Water"), "Land"), (1, "Time"), (2, "Space")] # calculate_damage (attacks) -> [(1, "Fire"), (3, "Water"), (1, "Space")] # #Because: #3 Fire 2 ce 1 Fire #5 Water + 2 Land = 3 Water #1 Time + 2 Space = 1 Space # #HINT: For each of the three pairs, try thinking of #one as positive and the other as negative.
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
Related questions
Question
100%
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
Knowledge Booster
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
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education