Sir, why are we taking mod of Particle Count with Max Count+1 as chamber value and then dividing it by Max Count+1… ?

Which algorithm is this ?

Sir, why are we taking mod of Particle Count with Max Count+1 as chamber value and then dividing it by Max Count+1… ?

Which algorithm is this ?

If there are A particles, starting from 1 every time you reach Max Count + 1 particles, 1 particle is moved to the consecutive chamber and whole Max Count + 1 particles are destroyed.

So,

Particles left in the chamber is A % (Max Count + 1)

And particles transferred to the next chamber is A / (Max Count + 1) since this will happen again and again starting from 1 to Max Count + 1.

See this video it might help you Click

2 Likes

The solution is basically writing A in the base of n+1. This is because at every n+1 particle the carry is taken over to the the next chamber. Think of this in terms of binary and then you’ll be able to apply this for every base n+1. That being said, I’m not able to pass the 3rd test case even though I am 100% sure of my solution (all of them are clearing in 0.00s). Is there anything I should look out for in particular ?

1 Like