Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How to complete this code on python. send me the code which I can copy and paste. Thank you. Find the Bad Diff When working

How to complete this code on python. send me the code which I can copy and paste. Thank you.

Find the Bad Diff When working with code in a repository, sets of changes are known as diffs. Diffs can touch a single line of code or they can edit, add, and delete multiple files. Diffs are supposed to add features or improve the code in some way, but sometimes they introduce a bug and if not caught soon, it can be non-trivial to find the source of the new bug. When this happens, it is useful to go back and find the diff where the bug first appeared so you can isolate its cause. In this assignment, you will write a function called find_bad_diff() which will take three arguments: the id of the first diff to check, the id of the last diff to check, and a DiffChecker object. Diff ids are sequential and have no gaps (i.e. all diffs between first_diff and last_diff exist). The function will return the id of the first diff that contains the bug or None if it is not in the range. The DiffChecker object has one method: doesTestFail(diff). Given a diff id, it will return True if the diff contains the bug or False if it doesn't. You can create your own DiffChecker for testing via d = DiffChecker(123), which will return False for all diffs below 123 and True for all diffs equal to or above 123. In the context of the function as I scaffolded it, you can check if the diff is bad via: diff_checker.doesTestFail(diff_number). Grading will take into account the efficiency of the solution. That is, a solution that grows linearly in time with the range of diffs to check will not get full credit. Expected Behavior: find_bad_diff(10, 30, DiffChecker(12)) == 12 find_bad_diff(10, 30, DiffChecker(3)) == None find_bad_diff(10, 30, DiffChecker(35)) == None

class DiffChecker: def __init__(self, bad_diff): self.__bad_diff = bad_diff def doesTestFail(self, diff): return diff >= self.__bad_diff

def find_bad_diff(first_diff, last_diff, diff_checker):

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Next Generation Databases NoSQLand Big Data

Authors: Guy Harrison

1st Edition

1484213300, 978-1484213308

More Books

Students also viewed these Databases questions

Question

Describe the provisions concerning leases involving real estate.

Answered: 1 week ago

Question

7. Discuss the implications of a skill-based pay plan for training.

Answered: 1 week ago

Question

4. Make recommendations on steps to take to melt the glass ceiling.

Answered: 1 week ago