Solution to 943566 should be BAQUZ not BAQTZ. let me know if i'm wrong


solution to 943566 should be BAQUZ not BAQTZ. let me know if i’m wrong


You can try the reverse conversion to verify.
BAQUZ = 26 + 21 * 26 + 17 * 26 * 26 + 1 * 26 * 26 * 26 + 2 * 264 = 943592
BAQTZ = 26 + 20 * 26 + 17 * 26 * 26 + 1 * 26 * 26 * 26 + 2 * 26
4 = 943566
BAQTZ seems correct in this case.


seems like you both right - on the divide way its 943566 !! but when i try to reverse it -its turn out to be 943592 !
did u figuer it out ??


this is the case when you get a%26==0 during process let me explain why , assume you get a%26=1 that means you have 1 more than something*26 so when you divide why 26 this one gets removed but in case of a%26=0 that value that get removed is 0 instead of 26 so in that case you should subtract a with 26 to remove 26 and then divide with 26


BAQUZ is the right answer. You have taken the equivalent of Z as 26, but Z is equivalent to 0. Any number system with base N can have 0 to N-1 distinct digits. For example, Octal number system has 8 distinct digits which are 0 to 7. For base of 26, 0-25 are those digits. 26 cannot occur. Hence, BAQUZ is the correct answer.
Also, BAQUZ=0x26^0+21x26^1+17x26^2+1x26^3+2x26^4=943566.
Please verify the answer once and reply if there is a flaw in my logic. :slight_smile:


@amitprasad your logic is correct but here qsn is regarding excel sheet.


Your logic is completely right
But you are not considering this particular case
When A is completely divisible by 26, in that case, we need to reduce A using this condition.

if (rem==0)
str+= ‘Z’;
A = (A/26)-1;


naveen can u please explain thi logic i.e why we need to do so.


There could be issue in directly doing integer division at end of loop by 26
This would be lossy. We can get unit digit by % (if 0 treat that as 26)
Now since unit digit is consumed substract A by unit difit extracted and divide A by 26 to A ready for next iteration


just take the case n=26
you would have used the condition somewhere that
while (n!=0){ …


in the above case when say n=26 the loop will run 2 times and not once as after first division n=1,then in the next iteration after n=1/26=0 happens the loop will stop and you would have added an extra A to your answer. Hope it is clear why we have to decrease the n by 1 after division or n by 26 before division if the case of n%26==0 ever occurs


Just try to convert 52 (meaning A=52) and you’ll see the problem.
With the wrong code you’ll get BZ instead of AZ.


The answer is varying due to value of this z.
someone considering the Z=0 and on the other hand some one is considering the value of the Z to be 16 i.e. Z=26.
Thinking numerically ,when we are dividing this 943566 by 26.The remainder is 0 and are converting it to Z.
But when we are converting this BAQUZ to number we are considering Z=26 ,which is alphabetically positional value of Z and it’s becoming 943592.
If Z=0 , then BAQUZ to number is 943566.


try n=26 to understand whats happening!


I just unlocked the solution. I just got Zero point. And here is the secret… BAQTZ is the correct answer for 943566. The solution is giving BAQTZ for this number.


Thank you so much for this detailed explanation, got stuck there for about an hour.


Try to dry run for A = 26

according to your approach I would assume:
26%26 = 0
A = 26//26
// 1 (now it should be zero not one, isn’t it)
// Now when ever remender is 0 subtract 1
This will fix ur code


in base 10(decimal) our digits goes from 0 to 9
but here they want us to to be it from 1 to 26 rather than 0 to 25.
so to make it similar just do A=A-1 in the beginning of every loop.
rest of it follows the procedure similar to the binary conversion of a decimal number.


I found this thread to be very interesting and informative. The silly mistake some of us were doing is considering the conversion to be like decimal to hexadecimal or some other. But actually this problem is a bit different. And what is difference is already explained in this discussion.