Skip to main content
Commonmark migration
Source Link

#Pyth, 20 19 bytes

Pyth, 20 19 bytes

1 byte thanks to xnor.

%"#%06x"-t^8 8itz16

Try it online. Test suite.

###Explanation

Explanation

  • z is the input
  • tz removes the #
  • itz16 parses as a hexadecimal number
  • t^8 8 calculates 88 - 1
  • -t^8 8itz16 calculates 88 - 1 - input
  • %"#%06x"-t^2 24itz16 formats it into a zero-padded 6-character hex string and adds the #

#Pyth, 20 19 bytes

1 byte thanks to xnor.

%"#%06x"-t^8 8itz16

Try it online. Test suite.

###Explanation

  • z is the input
  • tz removes the #
  • itz16 parses as a hexadecimal number
  • t^8 8 calculates 88 - 1
  • -t^8 8itz16 calculates 88 - 1 - input
  • %"#%06x"-t^2 24itz16 formats it into a zero-padded 6-character hex string and adds the #

Pyth, 20 19 bytes

1 byte thanks to xnor.

%"#%06x"-t^8 8itz16

Try it online. Test suite.

Explanation

  • z is the input
  • tz removes the #
  • itz16 parses as a hexadecimal number
  • t^8 8 calculates 88 - 1
  • -t^8 8itz16 calculates 88 - 1 - input
  • %"#%06x"-t^2 24itz16 formats it into a zero-padded 6-character hex string and adds the #
replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link

#Pyth, 20 19 bytes

1 byte1 byte thanks to xnorxnor.

%"#%06x"-t^8 8itz16

Try it online. Test suite.

###Explanation

  • z is the input
  • tz removes the #
  • itz16 parses as a hexadecimal number
  • t^8 8 calculates 88 - 1
  • -t^8 8itz16 calculates 88 - 1 - input
  • %"#%06x"-t^2 24itz16 formats it into a zero-padded 6-character hex string and adds the #

#Pyth, 20 19 bytes

1 byte thanks to xnor.

%"#%06x"-t^8 8itz16

Try it online. Test suite.

###Explanation

  • z is the input
  • tz removes the #
  • itz16 parses as a hexadecimal number
  • t^8 8 calculates 88 - 1
  • -t^8 8itz16 calculates 88 - 1 - input
  • %"#%06x"-t^2 24itz16 formats it into a zero-padded 6-character hex string and adds the #

#Pyth, 20 19 bytes

1 byte thanks to xnor.

%"#%06x"-t^8 8itz16

Try it online. Test suite.

###Explanation

  • z is the input
  • tz removes the #
  • itz16 parses as a hexadecimal number
  • t^8 8 calculates 88 - 1
  • -t^8 8itz16 calculates 88 - 1 - input
  • %"#%06x"-t^2 24itz16 formats it into a zero-padded 6-character hex string and adds the #
added 230 characters in body
Source Link
PurkkaKoodari
  • 17.9k
  • 2
  • 35
  • 91

#Pyth, 2020 19 bytes

1 byte thanks to xnor.

%"#%06x"-t^2t^8 24itz168itz16

Try it online.Try it online. Test suite.Test suite.

###Explanation

  • z is the input
  • tz removes the #
  • itz16 parses as a hexadecimal number
  • t^2t^8 248 calculates 28248 - 1
  • -t^2t^8 24itz168itz16 calculates 28248 - 1 - input
  • %"#%06x"-t^2 24itz16 formats it into a zero-padded 6-character hex string and adds the #

#Pyth, 20 bytes

%"#%06x"-t^2 24itz16

Try it online. Test suite.

###Explanation

  • z is the input
  • tz removes the #
  • itz16 parses as a hexadecimal number
  • t^2 24 calculates 224 - 1
  • -t^2 24itz16 calculates 224 - 1 - input
  • %"#%06x"-t^2 24itz16 formats it into a zero-padded 6-character hex string and adds the #

#Pyth, 20 19 bytes

1 byte thanks to xnor.

%"#%06x"-t^8 8itz16

Try it online. Test suite.

###Explanation

  • z is the input
  • tz removes the #
  • itz16 parses as a hexadecimal number
  • t^8 8 calculates 88 - 1
  • -t^8 8itz16 calculates 88 - 1 - input
  • %"#%06x"-t^2 24itz16 formats it into a zero-padded 6-character hex string and adds the #
Source Link
PurkkaKoodari
  • 17.9k
  • 2
  • 35
  • 91
Loading