New Problems - Kaprekars Constant (and number bases)

Back to Topic List

admin (Kevin)     2024-09-07 04:18:12
User avatar

Hello all!

Four new problems have been uploaded - the first three deal with expressing numbers in other bases, namely in Binary, in Hexadecimal, and also in any Arbitrary Base.

These three problems are intended as prerequesites to the fourth problem which introduces Kaprekar's Constant.

aszaloki     2024-09-07 09:55:06

Hi Kevin!

33 ‐ Binary Numbers

In the expected result there is minor error: After the first set of numbers (decimal to binary conversion) a space character is missing. So the first result number of the second part (binary to decimal conversion) is "glued" to the end of the last result number of the first set.

aszaloki     2024-09-07 10:02:06

The problem is the same with #34 - Hexadecimal Numbers

admin (Kevin)     2024-09-07 16:13:58
User avatar

Hi Adam!

Many thanks for pointing that out - it should be resolved now :)

aszaloki     2024-09-09 07:18:13

Hi Kevin!

I can confirm that it is OK now, thanks! :)

aszaloki     2024-09-09 09:49:13

Hi Kevin,

I found another difference between my results and the expected answers in the "Kaprekars Constant" problem. E.g.:

input | my result | expected asnwer

110 4 | 3 0 | 4 132

322 10 | 3 0 | 7 495

I have checked my code step by step and it seems my values are correct. Do I understand something not correctly?

Thanks!

admin (Kevin)     2024-09-09 11:58:36
User avatar

Hi Adam!

I should have been a bit more clear in the prompt... When the algorithm is performed on an n-digit number and the result is less than n digits, then the leading zeroes should be preserved in order to maintain an n- digit number.

For example in Base-10, instead of 322 -> 99 -> 0, it should be 322 -> 099 -> 891 -> 792 -> 963 -> 594 -> 495

Otherwise I think your logic looks correct for how the problem was originally stated! I updated with a note about the leading zeroes so now the prompt should also be correct :)

aszaloki     2024-09-09 13:03:54

Ok, thank you Kevin, I suspected that maybe leading zeros is the problem with mine :) Thanks for clarification.

Please login and solve 5 problems to be able to post at forum