Four questions, one clock
CodeSignal publishes the shape of the General Coding Assessment: 4 questions in 70 minutes, though an employer may change the time. All four are visible at once, you can work in any order, and you decide how to split the time.
Each question earns base points, and a bonus comes only from solving a question 100%, with a larger bonus for harder ones. So a question you finish completely is the goal. Read all four first, then start with one you are sure you can finish.
The timers on these exercises are ours: 10 minutes for tier 1 and 15 for tier 2. They are practice targets, not CodeSignal numbers.
In the visual, watch minutes_left fall as one example plan runs.
See it run
minutes_left = 70 plan = [("read all four", 5), ("first question", 15), ("second question", 20)] for step, minutes in plan: minutes_left -= minutes print(minutes_left)
One example plan. These splits are made up for illustration: you choose your own on the day.
Practice four questions, one clock
Exercise 1
After a practice test, marks holds one [passed, total] pair per question: how many of its tests passed, and how many it has.
Return how many questions are fully solved, as an integer.
Rules:
- A question is fully solved when
passedequalstotalandtotalis at least 1. - A pair with
totalof 0 was never submitted, so it does not count. - Empty
marksgives0.
Constraints: 0 ≤ len(marks) ≤ 100; 0 ≤ passed ≤ total ≤ 1000.
Example: solution([[10, 10], [7, 10]]) returns 1: the second question passes only some of its tests.
Exercise 2
total is the minutes on the clock and spent lists the minutes you have used so far, one entry per stretch of work.
Return the minutes left as an integer.
Rules:
- The clock stops at zero, so the answer is never below
0. - Empty
spentleaves all oftotal.
Constraints: 1 ≤ total ≤ 300; 0 ≤ len(spent) ≤ 100; 0 ≤ spent[i] ≤ 300.
Example: solution(70, [20, 15]) returns 35, and solution(70, [50, 30]) returns 0.
Exercise 3
estimates lists how many minutes you expect each question to take, and minutes is the time you have. You work on the quickest question first, then the next quickest, and so on.
Return how many questions you finish, as an integer.
Rules:
- You stop at the first question that no longer fits in the time left.
- A question that takes exactly the time left still fits.
Constraints: 0 ≤ len(estimates) ≤ 100; 1 ≤ estimates[i] ≤ 300; 0 ≤ minutes ≤ 300.
Example: solution([30, 10, 25, 15], 50) returns 3: 10, then 15, then 25 uses exactly 50 minutes.
The explanation and tasks are public. Running this lesson requires an account with course access.
Practice
Loading Python…Visualizer Watch your code run line by line
Run your code, then choose Play to follow its execution.