def colours (guess:tuple, hidden tuple) -> int: Preconditions: - guess is a sequence of four unique colours chosen from R, O, Y, G, B, V, - hidden is a sequence of four unique colours chosen from R, O, Y, G, B, V, Postconditions: output is number of correct colours in guess correct = 0 for colour in ('R','O','Y','G','B','V): if colour in guess and colour in hidden: correct = correct + 1 return correct colours (['R','B','O','G'],['R','B','V','O']) Q1(a) What is the worst-case complexity of colours?
def colours (guess:tuple, hidden tuple) -> int: Preconditions: - guess is a sequence of four unique colours chosen from R, O, Y, G, B, V, - hidden is a sequence of four unique colours chosen from R, O, Y, G, B, V, Postconditions: output is number of correct colours in guess correct = 0 for colour in ('R','O','Y','G','B','V): if colour in guess and colour in hidden: correct = correct + 1 return correct colours (['R','B','O','G'],['R','B','V','O']) Q1(a) What is the worst-case complexity of colours?
C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter4: Selection Structures
Section: Chapter Questions
Problem 14PP
Related questions
Question
![def colours (guess tuple, hidden tuple) -> int:
Preconditions:
- guess is a sequence of four unique colours chosen from R, O, Y, G, B, V,
- hidden is a sequence of four unique colours chosen from R, O, Y, G, B, V,
Postconditions: output is number of correct colours in guess
correct = 0
for colour in ('R','O','Y, 'G','B','V):
if colour in guess and colour in hidden:
correct = correct + 1
return correct
colours (['R','B','O','G'],['R','B',V,'O'])
Q1(a)
What is the worst-case complexity of colours?
What is the worst-case complexity of positions?
Explain your answers.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F79847c05-1f73-491c-a0a9-8bebd6776c50%2Fccb29fb4-7dc1-4442-98b0-b9cd73196837%2Fsm4nkah_processed.png&w=3840&q=75)
Transcribed Image Text:def colours (guess tuple, hidden tuple) -> int:
Preconditions:
- guess is a sequence of four unique colours chosen from R, O, Y, G, B, V,
- hidden is a sequence of four unique colours chosen from R, O, Y, G, B, V,
Postconditions: output is number of correct colours in guess
correct = 0
for colour in ('R','O','Y, 'G','B','V):
if colour in guess and colour in hidden:
correct = correct + 1
return correct
colours (['R','B','O','G'],['R','B',V,'O'])
Q1(a)
What is the worst-case complexity of colours?
What is the worst-case complexity of positions?
Explain your answers.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps

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

C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr

C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning

Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,

C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr

C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning

Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,

EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage

Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning