45
4
In this challenge, you will receive an input, convert it to hexadecimal, make a couple changes, and output the result.
Because they are only 16 characters in hexadecimal, your code will need to be as short as possible.
Examples
Examples are separated by a blank line. First line is input, second line shows the steps, third shows the output
234589
234589 -> 3945D -> 39454 -> 9A1E -> 9115 -> 239B -> 2392 -> 958
958
435234
435234 -> 6A422 -> 61422 -> EFEE -> 5655 -> 1617
1617
153
153 -> 99 -> 99 -> 63
1617
Steps
The input will always be a positive integer
In order to generate the output you will follow the following steps:
- Convert the input to hexadecimal
- Replace any letters with their index in the alphabet (e.g.
a -> 1, b -> 2
) - Convert the result back to hexadecimal
- If the result contains any letters, go to step 2. If not, output the result
This is code-golf so shortest code in bytes wins!
27+1 for the justification "Because they are only 16 characters in hexadecimal, your code will need to be as short as possible." – cat – 2015-12-19T18:29:33.663
1A test case that passes through a zero digit (which is an important edge case for my current approach):
749699 -> B7083 -> 27083 -> 69CB -> 6932 -> 1B14 -> 1214 -> 4BE -> 425 -> 1A9 -> 119 -> 77
– Martin Ender – 2015-12-19T18:53:16.7575Test case 153. Step 1 > 99, Step 2 --> 99, Step 3 --> 63, output 63. Correct? – edc65 – 2015-12-21T12:09:24.477
Yes for 153 I had not seen the code Flow explanation... – RosLuP – 2019-01-30T09:51:21.057
For what it's worth... 3 out of the top 4 answers return 99 on input 153 and Dennis's seg-faults on the current version of Jelly. I'm going to quit testing while I'm ahead :) Are we sure that example is correct? – dana – 2019-01-31T04:31:41.803