Skip to main content
added 110 characters in body
Source Link
movatica
  • 1.5k
  • 8
  • 9

Python 3, 72 7070 68 bytes

lambda x:'#'+''.join(f"{round(int(x[i:i+2],16)+8)//17):X}"for i in(1,3,5)) 

Try it online!Try it online!

This is a port of Grzegorz Oledzkis original answer, which I helped him golfing down.

Two features of Python 3 help us save bytes:

  • Floating point division by default
  • Format string literals

-2 bytes thanx to Jonathan Allan

Python 3, 72 70 bytes

lambda x:'#'+''.join(f"{round(int(x[i:i+2],16)/17):X}"for i in(1,3,5)) 

Try it online!

This is a port of Grzegorz Oledzkis original answer, which I helped him golfing down.

Two features of Python 3 help us save bytes:

  • Floating point division by default
  • Format string literals

Python 3, 72 70 68 bytes

lambda x:'#'+''.join(f"{(int(x[i:i+2],16)+8)//17:X}"for i in(1,3,5)) 

Try it online!

This is a port of Grzegorz Oledzkis original answer, which I helped him golfing down.

Two features of Python 3 help us save bytes:

  • Floating point division by default
  • Format string literals

-2 bytes thanx to Jonathan Allan

Source Link
movatica
  • 1.5k
  • 8
  • 9

Python 3, 72 70 bytes

lambda x:'#'+''.join(f"{round(int(x[i:i+2],16)/17):X}"for i in(1,3,5)) 

Try it online!

This is a port of Grzegorz Oledzkis original answer, which I helped him golfing down.

Two features of Python 3 help us save bytes:

  • Floating point division by default
  • Format string literals