Skip to main content
added 628 characters in body
Source Link
NinjaBearMonkey
  • 10.4k
  • 3
  • 37
  • 66

Retina, 1313 10 bytes

T`da-f`fT`w`G-a9A9-0

This usesThere are three parts to the code, separated by backticks (`): T specifies transliterate mode and, which replaces each character in the second part with its helpful feature that does reverse rangescorresponding character in the third part.

w is the same as traditional regex's \w, soor f_0-a9A-Za-z expands, which is expanded to fedcba_0123456789ABCDEFGH.... More thorough explanation coming soon

The second part is expanded to GFEDCBA9876543210, thanks to Retina's nifty ability to expand in reverse order. Put these on top of each other, and we get:

_0123456789ABCDEFGH...
GFEDCBA987654321000...
 ^^^^^^^^^^^^^^^^

Try the test suite online. Note that the last character, 0, is repeated to fit the length of the longer string, but we only care about the hexadecimal characters, shown by carets.

Thanks to Martin Büttner for suggesting this approach.

Try the test suite online.

Retina, 13 bytes

T`da-f`f-a9-0

This uses transliterate mode and its helpful feature that does reverse ranges, so f-a expands to fedcba. More thorough explanation coming soon.

Try the test suite online.

Retina, 13 10 bytes

T`w`G-A9-0

There are three parts to the code, separated by backticks (`): T specifies transliterate mode, which replaces each character in the second part with its corresponding character in the third part.

w is the same as traditional regex's \w, or _0-9A-Za-z, which is expanded to _0123456789ABCDEFGH....

The second part is expanded to GFEDCBA9876543210, thanks to Retina's nifty ability to expand in reverse order. Put these on top of each other, and we get:

_0123456789ABCDEFGH...
GFEDCBA987654321000...
 ^^^^^^^^^^^^^^^^

Note that the last character, 0, is repeated to fit the length of the longer string, but we only care about the hexadecimal characters, shown by carets.

Thanks to Martin Büttner for suggesting this approach.

Try the test suite online.

added 288 characters in body
Source Link
NinjaBearMonkey
  • 10.4k
  • 3
  • 37
  • 66

Retina, 13 bytes

T`da-f`f-a9-0

Try it online. This uses transliterate mode and its helpful feature that does reverse ranges, so f-a expands to fedcba. More thorough explanation coming soon.

Try the test suite online.

Retina, 13 bytes

T`da-f`f-a9-0

Try it online.

Retina, 13 bytes

T`da-f`f-a9-0

This uses transliterate mode and its helpful feature that does reverse ranges, so f-a expands to fedcba. More thorough explanation coming soon.

Try the test suite online.

Source Link
NinjaBearMonkey
  • 10.4k
  • 3
  • 37
  • 66

Retina, 13 bytes

T`da-f`f-a9-0

Try it online.