-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChuckNorris
50 lines (38 loc) · 901 Bytes
/
ChuckNorris
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import sys
import math
message = input()
bin_message = ''
for letter in message:
temp_bin = bin(ord(letter))[2:]
#print(temp_bin)
if len(temp_bin) < 7:
temp_bin = '0' + temp_bin
bin_message += temp_bin
#print(bin_message)
is_zero = '00 '
is_one = '0 '
more = '0'
temp_char = ''
final_char = ''
count = 0
for char in bin_message:
if char is temp_char:
count +=1
else:
if temp_char is '0':
final_char += is_zero
elif temp_char is '1':
final_char += is_one
for i in range(0, count):
final_char += more
if count > 0:
final_char += ' '
temp_char = char
count = 1
if temp_char is '0':
final_char += is_zero
elif temp_char is '1':
final_char += is_one
for j in range(0, count):
final_char += more
print (final_char)