Skip to content

Instantly share code, notes, and snippets.

@ZengetsuFR
Created June 3, 2015 07:07
Show Gist options
  • Save ZengetsuFR/710b094e76e4163f0734 to your computer and use it in GitHub Desktop.
Save ZengetsuFR/710b094e76e4163f0734 to your computer and use it in GitHub Desktop.
Résolution du jeu "Chuck Norris" sur le site codingame.com
import sys, math, binascii
# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.
MESSAGE = raw_input()
string =""
result =""
#convertir code ascii en binaire
for caracter in MESSAGE: string += str(bin(int(binascii.hexlify(caracter), 16))[2:].zfill(7))
output = string[0]
i=0
for char in string[1:]:
if char == string[i]:
output+= char
else:
output+=" " + char
i+=1
listOfString = output.split(" ")
output = ""
#dico pour appliquer le code de chuck
dicoEncoding = {"0":"00","1":"0"}
for string in listOfString:
key = string[0]
string = dicoEncoding[key] + " 0" + string[1:]
output += string + " "
result = output[0:].replace("1","0")
print result.strip()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment