Your task is to write a function total_damage(actions_list: list[str]) -> int that calculates the total damage you will deal according to your actions_list which is a sequence of strings representing types of combat types: Q or E. The total damage is calculated as follows: • The total damage is the sum of all damages dealt. • A single Q action deals 10 damage, and a single E action deals 7 damages. • Whenever combo sequence QQE is performed, you will deal an extra 20 damages. • Each input action can only be a part of at most one combo.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

Python Language - Total Damage

The combat system in Hack & Slash games typically require a player to deal damages to the enemy with one or more
types of the combat actions. Different types of combat actions can deal different damage amounts. However, a
certain sequence of two or more different actions, called combo can deal extra damages to the enemy.
Your task is to write a function total_damage (actions_list: list[str]) -> int that calculates the total damage you
will deal according to your actions_list which is a sequence of strings representing types of combat types: e or
E. The total damage is calculated as follows:
• The total damage is the sum of all damages dealt.
• A single Q action deals 10 damage, and a single E action deals 7 damages.
• Whenever combo sequence QQE is performed, you will deal an extra 20 damages.
• Each input action can only be a part of at most one combo.
For example, given the actions_list
['Q', 'Q','Q', 'E', 'E'] then the first 3 Q 's will deal 10+1O+10 damages,
%3D
then E will deal 7 damages. However, the second to forth actions satisfy the combo sequence, so an extra 20
damages will be dealt. The last E deals 7 more damages. Hence, the total damage would be 10+10+10+7+20+7 =
64 .
Examples
total_damage ([])
== 0
total_damage(['Q'])
== 10
total_damage (['E'])
total_damage (['Q', 'q'])
total_damage (['Q', 'Q', 'E'])
total_damage (['Q', 'Q', 'Q', 'E'])
total_damage (['Q', 'Q', 'q', 'E', 'E'])
total_damage (['Q', 'Q', 'E', 'Q', 'Q', 'Q'])
total_damage (['Q', 'Q', 'E', 'Q', 'Q', 'E'])
total_damage (['Q', 'Q', 'q', 'Q', 'E', 'Q', 'Q', 'E'])
total_damage (['Q', 'Q', 'Q', 'Q', 'E', 'Q', 'Q', 'E', 'Q', 'E', 'E']) == 138
7
==
== 20
== 47
== 57
== 64
== 77
== 94
== 114
Transcribed Image Text:The combat system in Hack & Slash games typically require a player to deal damages to the enemy with one or more types of the combat actions. Different types of combat actions can deal different damage amounts. However, a certain sequence of two or more different actions, called combo can deal extra damages to the enemy. Your task is to write a function total_damage (actions_list: list[str]) -> int that calculates the total damage you will deal according to your actions_list which is a sequence of strings representing types of combat types: e or E. The total damage is calculated as follows: • The total damage is the sum of all damages dealt. • A single Q action deals 10 damage, and a single E action deals 7 damages. • Whenever combo sequence QQE is performed, you will deal an extra 20 damages. • Each input action can only be a part of at most one combo. For example, given the actions_list ['Q', 'Q','Q', 'E', 'E'] then the first 3 Q 's will deal 10+1O+10 damages, %3D then E will deal 7 damages. However, the second to forth actions satisfy the combo sequence, so an extra 20 damages will be dealt. The last E deals 7 more damages. Hence, the total damage would be 10+10+10+7+20+7 = 64 . Examples total_damage ([]) == 0 total_damage(['Q']) == 10 total_damage (['E']) total_damage (['Q', 'q']) total_damage (['Q', 'Q', 'E']) total_damage (['Q', 'Q', 'Q', 'E']) total_damage (['Q', 'Q', 'q', 'E', 'E']) total_damage (['Q', 'Q', 'E', 'Q', 'Q', 'Q']) total_damage (['Q', 'Q', 'E', 'Q', 'Q', 'E']) total_damage (['Q', 'Q', 'q', 'Q', 'E', 'Q', 'Q', 'E']) total_damage (['Q', 'Q', 'Q', 'Q', 'E', 'Q', 'Q', 'E', 'Q', 'E', 'E']) == 138 7 == == 20 == 47 == 57 == 64 == 77 == 94 == 114
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY