You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.8 KiB
60 lines
1.8 KiB
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Brython</title>
|
|
<link rel="stylesheet"href="../css/all.css" />
|
|
</head>
|
|
<body>
|
|
<div class="enigme">
|
|
<h2>
|
|
Coder un fonction binaire2unaire qui prend en argument un nombre binaire et le code via le codage Chucknorris.
|
|
</h2>
|
|
</div>
|
|
|
|
<h1 id="result" class="hidden"></h1>
|
|
|
|
<button onclick="run_init()">run</button>
|
|
<button onclick="submit()">submit</button>
|
|
<button onclick="aide()" id="buttonAide">Aide</button>
|
|
<button onclick="rappel()" id="buttonRappel">Rappel</button>
|
|
<p id="textAide"></p>
|
|
<p id="textRappel"></p>
|
|
<div class='editor_class' id='editor'>def binaire2unitaire(x):
|
|
rep=0
|
|
pre=x[0]
|
|
unitaire=""
|
|
for i in x:
|
|
if(pre==i):
|
|
rep+=1
|
|
else:
|
|
if(pre=="1"):
|
|
unitaire=unitaire+"0 "
|
|
else:
|
|
unitaire=unitaire+"00 "
|
|
for j in range(rep):
|
|
unitaire=unitaire+"0"
|
|
unitaire=unitaire+" "
|
|
rep=1
|
|
pre=i
|
|
if(pre=="1"):
|
|
unitaire=unitaire+"0 "
|
|
else:
|
|
unitaire=unitaire+"00 "
|
|
for i in range(rep):
|
|
unitaire=unitaire+"0"
|
|
return unitaire
|
|
</div>
|
|
<div class='compiler_class'>
|
|
<textarea id='console' readonly></textarea>
|
|
</div>
|
|
|
|
<script src="https://ajaxorg.github.io/ace-builds/src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
|
|
<script src="https://raw.githack.com/pythonpad/brython-runner/master/lib/brython-runner.bundle.js" type="text/javascript" charset="utf-8"></script>
|
|
<script src="../javascript/chuckNorris.js"></script>
|
|
|
|
</body>
|
|
</html>
|