Reported July 2026
IDFCmath

Minimum Cake Cuts

Reported by candidates from IDFC's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live IDFC OA. Under 2s to a working solution.
Founder's read

The mistake that sinks most first attempts at IDFC's Minimum Cake Cuts, reported in July 2026, is simulating the cutting. People loop over cakes, split pieces, and track fractions, then hit a wall of edge cases. This is a math problem in disguise, and the whole answer is one line built on a GCD. The OA gives you cakes and people, both up to 1000, and asks for the fewest cuts so everyone gets an equal share. If you see the closed form, you finish in minutes. If you blank on why it works, StealthCoder runs invisibly as a safety net during the live OA and surfaces the solution while you keep your cool.

The problem

You have cakes identical whole cakes and people people. Divide all of the cake equally so that every person receives exactly the same total amount.
A cut divides one existing cake piece into two pieces. Whole cakes and cut pieces may be distributed independently, and one person may receive multiple pieces.
Return the minimum number of cuts required.

Function
minimumCakeCuts(cakes: int, people: int) → int

Examples
Example 1
cakes = 2
people = 6
return = 4
Each person must receive one third of a cake. Cutting each cake into three equal pieces takes two cuts per cake, for 4 cuts total.
Example 2
cakes = 3
people = 2
return = 1
Give each person one whole cake, cut the remaining cake in half, and give one half to each person.

Constraints
1 <= cakes <= 10^3
1 <= people <= 10^3

Reported by candidates. Source: FastPrep

Pattern and pitfall

The answer is people - gcd(cakes, people). Here's why. Treat each piece as a link between a cake and a person. A group of a cakes feeding b people that are all connected needs at least a + b - 1 pieces. The number of independent groups can't exceed g = gcd(cakes, people). Total pieces are at least cakes + people - g, and since pieces equal cakes plus cuts, cuts are at least people - g. Check it: 2 cakes and 6 people gives 6 - 2 = 4. 3 cakes and 2 people gives 2 - 1 = 1. The pitfall is multiplying per-cake cuts naively or reducing the fraction wrong. Edge cases fall out free: when people divides cakes, gcd equals people and you get 0 cuts. With one person, you get 0. If you freeze on the proof, StealthCoder is your hedge in the live OA, but the code is three lines.

Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.

If this hits your live OA

You can drill Minimum Cake Cuts cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass IDFC's OA.

IDFC reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Minimum Cake Cuts FAQ

What's the trick to Minimum Cake Cuts?+

Return people minus gcd(cakes, people). The GCD tells you how many independent groups the cakes and people split into. Each group needs the minimum number of cuts, and the sum collapses to that one formula. No simulation or fraction tracking needed.

How hard is this problem really?+

Easy to code, medium to see. Once you know the GCD formula it's three lines. The difficulty is realizing it's a number theory problem, not a cutting simulation. Test your formula against both examples before submitting: 4 and 1.

Why does the answer use gcd of cakes and people?+

Dividing both by their gcd gives smaller groups that can be solved on their own. Each coprime group of c' cakes and p' people needs p' - c' cuts plus the shared structure, and summed across g groups it equals people - g. The gcd is the max number of groups.

What edge cases should I test?+

Test people = 1 (answer 0), cakes divisible by people (answer 0), cakes smaller than people with coprime values like 3 and 2 (answer 1), and equal values (answer 0). Also try 1000 and 1000 and 1 and 1000, where the answer is 999. The formula handles all of them.

How do I prepare for this in 48 hours?+

Don't grind. Learn the Euclidean gcd, then practice reducing counting problems to graph components or ratio reductions. Write this solution once from memory, check it against both examples, and move on. Time complexity is O(log n), so performance is never the issue.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with IDFC.

OA at IDFC?
Invisible during screen share
Get it