Advertisement
Guest User

Chuck Norris [CodinGame]

a guest
Feb 14th, 2021
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. import sys
  2. import math
  3.  
  4. # Auto-generated code below aims at helping you parse
  5. # the standard input according to the problem statement.
  6.  
  7. message = input()
  8. s = ""
  9. f = ""
  10. for c in message:
  11.     b = bin(int(ord(c)))[2:]
  12.  
  13.     if len(b) % 7 != 0:
  14.         temp = "0" * (7-(len(b)%7))
  15.         temp += b
  16.         b = temp
  17.     s += b
  18.  
  19. i=0
  20. while i < len(s):
  21.    
  22.     if s[i] == '1':
  23.         f += "0 0"
  24.  
  25.     else:
  26.         f += "00 0"
  27.  
  28.     c = 0
  29.     while i < len(s)-1 and s[i] == s[i+1]:
  30.         c+= 1
  31.         i+=1
  32.  
  33.     f += ("0" * c) + " "
  34.     i += 1
  35.  
  36. print(f.rstrip())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement