1
\$\begingroup\$

This is a code golf puzzle: shortest byte count wins. The program should do the following (standard loopholes obviously forbidden):

  1. Input a hexadecimal number
  2. Convert to octal
  3. Then interpret the digits as if in decimal (765 octal -> 765 decimal)
  4. Divide the number by two
  5. Convert to hexadecimal

Example:

Input: 4a3d Output: 5809.8

4a3d -> 45075 -> 45075 -> 22537.5 -> 5809.8
\$\endgroup\$
9
  • \$\begingroup\$ What's with the downvote? \$\endgroup\$ Apr 14 '18 at 14:38
  • 1
    \$\begingroup\$ Welcome to PPCG! I'm not the downvoter, but personally I'd vote this as a duplicate of base-conversion challenge, since that's the same, just repeated. I'd suggest you to use our sandbox next time, it can help detect potential problems in the challenge. \$\endgroup\$
    – RedClover
    Apr 14 '18 at 14:44
  • 1
    \$\begingroup\$ Hello, welcome to the site. I downvoted this challenge because it is a series of tasks, with no real motivation. I don't think the challenge is interesting. That being said don't feel discouraged to keep writing questions. Just because I think this challenge is bad doesn't mean I think you won't write good challenges in the future. \$\endgroup\$
    – Grain Ghost
    Apr 14 '18 at 15:03
  • 2
    \$\begingroup\$ The most recent challenge I have upvoted was this. The main criteria I look for in a question are 1) Whether the challenge offers something new I haven't seen before 2) Whether the challenge is cohesive, that is whether its internal parts make sense with one another. 3) an arbitrary do I think it is fun criterion. If you want to get good at writing challenges I would suggest reading this. You might also look at this. \$\endgroup\$
    – Grain Ghost
    Apr 14 '18 at 15:14
  • 1
    \$\begingroup\$ @SriotchilismO'Zaic It's been about a year since I created this question. Thanks for the feedback you gave, as it really helped me in future questions to avoid this mistake! \$\endgroup\$ May 3 '19 at 23:38
1
\$\begingroup\$

Javascript,56 53 52 bytes

-3 bytes thanks to @ovs

-1 byte thanks to @Arnauld

p=parseInt,a=>(p(p(a,16)[s='toString'](8))/2)[s](16)

toString on an integer converts the integer to a string in that base.

Try it online!

\$\endgroup\$
1
  • \$\begingroup\$ Had no idea the .toString(base) thing existed. Upvote for teaching me something new! \$\endgroup\$ Apr 14 '18 at 14:45
0
\$\begingroup\$

Perl 6, 30 bytes

{(:16($_).base(8)/2).base(16)}

Try it online!

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.