Characters in strings are sometimes represented as their ASCII hexadecimal codes. Printable characters have two hex digits in their representation. Swapping those digits leads to another character, which will be our output.
The table of relevant character codes can be found on Wikipedia.
- Take a string as input.
- For each character:
- Find corresponding hex value of ASCII code.
- Swap (reverse) the hex digits.
- Convert back to character.
- Output the new string.
- To make thinks easier, let's consider only characters "reversible" within standard printable ASCII range - that is codepoints (in hex):
- Input and output should be strings or closest equivalent in your language of choice.
- You may assume the input is non-empty.
- This is code-golf, the usual rules apply.
input: debug hex codes: 64 65 62 75 67 reversed: 46 56 26 57 76 output: FV&Wv
bcd <-> &6F 234 <-> #3C screw <-> 76'Vw debug <-> FV&Wv BEEF <-> $TTd 7W66V77 <-> success "#$%&'234567BCDEFGRSTUVWbcdefgrstuvw <-> "2BRbr#3CScs$4DTdt%5EUeu&6FVfv'7GWgw