Feature #5: Compilation Step Failure
Implementing the "Compilation Step Failure" feature for our "Language Compiler" project.
We'll cover the following
Description
Large software consists of many source files and libraries. The software as a whole can only compile if all the constituent files compile successfully with the required libraries. The multi-file compilation is generally structured as a number of build steps that must be performed sequentially so that the dependencies of files and libraries are met. An individual build step can include the compilation of a source file or library.
Assume that we are working with a system that specifies the build as steps 1
through n
, and the steps must be performed in ascending order. If a build step fails, repeating all the build steps is inefficient. The successful steps should not be repeated. When a build fails, you get an error message, but you don’t know which step failed. You have access to an API call, is_failed_step(i)
, which returns true if build step i
failed. Otherwise, it will return false. If there was a total of forty steps and step 28 failed, the compilation will stop, and is_failed_step(i)
will return true as long as i >= 28
. You want to efficiently determine the first build step that must be repeated.
For instance, if you have n = 40
steps and the steps 28
to 40
fail. The API call is_failed_step(i)
will give True
for 28
to 40
. Your module should then use these resources to output the first step that failed, i.e., 28
.
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.