fork(1) download
  1. raw = """
  2. ##### #### ### #### #####
  3. # # # # # # # # #
  4. ##### #### # # # ####
  5. # # # # # # # # #
  6. # # #### ### #### #####
  7. """
  8.  
  9. raw_rows = raw.strip().split("\n")
  10.  
  11. def chunk_it(l, n):
  12. return [l[i:i+n-1] for i in range(0, len(l), n)]
  13.  
  14. pixels = ["".join(l) for l in zip(*(chunk_it(l, 6) for l in raw_rows))]
  15. # example: A --> "###### ####### ## #"
  16.  
  17. numeric = [int(s.translate({ord("#"): "1", ord(" "): "0"}),2) for s in pixels]
  18. # example: A --> 33095217
  19.  
  20.  
  21. def base36encode(number):
  22. alphabet, base36 = ['0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ', '']
  23. while number:
  24. number, i = divmod(number, 36)
  25. base36 = alphabet[i] + base36
  26. return base36 or alphabet[0]
  27.  
  28. codes = " ".join([base36encode(c) for c in numeric])
  29. print(codes)
  30.  
Success #stdin #stdout 0.03s 9984KB
stdin
Standard input is empty
stdout
JPCFL J2UKE 92Y3Y J2KAM JOMCF