• + 2 comments

    Hi Partha, dont make low of your self. Whenever you dont get it take a small example. I will try to help with one.

    consider 2,x; The main thing you want to do is make a singleton( or the minimum posssible number of) choice per a candidate. a)If differnce between x and 2 is 5: -adding 0 makes it divisble by 5. (you only made one choice on x). -adding 1 or 2 makes it you to have more number of choices. b)If differnce between x and 2 is 4:

    -adding 1 makes it divisble by 5. (you only made one choice on x).  
    
    -adding 0 or 2 makes it you to have more number of choices.
    

    c)If differnce between x and 2 is 3:
    -adding 2 makes it divisble by 5. (you only made one choice on x).
    -adding 0 or 1 makes it you to have more number of choices.
    d)If differnce between x and 2 is 2:
    -adding 0 makes it divisble by 2. (you only made one choice on x). -adding 1 or 2 makes it you to have more number of choices. e)If differnce between x and 2 is 1:
    -adding 0 makes it divisble by 1. (you only made one choice on x).
    -adding 1 or 2 makes it you to have more number of choices.
    f)If differnce between x and 2 is 6:
    -adding 1 makes it divisble by 5. (you only made two choices on x, first divide by 5 then reminder by divided 2). //same number of choices in this case even by adding 0.
    -adding 2 makes it you to have more number of choices.

    So for every candidate you add some base (0 or 1 0r 2) and consider the only the base that gives you minimum choices.

    But why I need add some base?

    A basic divisibility exaple. 9 is not perfectly divisible 5 but adding 1 to 9 makes it 10 and now perfectly divisble by 5.

    But why base only till 0,1,2 and not more than 2?

    if the diffence between x and y is:
    a)4 adding 1 is div by 5
    b)3 adding 2 is div by 5
    c)2 it is div by 2
    d)7 is div by 5 followed by 2
    e)8 adding 2 is div by 5 followed by 2
    f)9 adding 1 is div by 5 followed by 2
    Did you observe the base is cycling around 0,1,2.so you never need not go beyond 2