scripts

random scripts
git clone https://git.parazyd.org/scripts
Log | Files | Refs

hex-contrast.py (481B)


      1 #!/usr/bin/env python3
      2 # Spit out contrast of given stdin hex value(s)
      3 # One value per line.
      4 
      5 from sys import stdin
      6 
      7 hexmap = {
      8     '#': '#',
      9     '0': 'f',
     10     '1': 'e',
     11     '2': 'd',
     12     '3': 'c',
     13     '4': 'b',
     14     '5': 'a',
     15     '6': '9',
     16     '7': '8',
     17     '8': '7',
     18     '9': '6',
     19     'a': '5',
     20     'b': '4',
     21     'c': '3',
     22     'd': '2',
     23     'e': '1',
     24     'f': '0',
     25 }
     26 
     27 for i in stdin.read().split('\n'):
     28     val = ''
     29     for j in i:
     30         val += hexmap[j.lower()]
     31     print(val)