5 nouveaux défis
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1 +1,2 @@
|
||||
.vscode/
|
||||
.vscode/
|
||||
chocogrenouille/
|
||||
|
||||
BIN
L'écharpe de Mme Weasley.png
Normal file
BIN
L'écharpe de Mme Weasley.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
24
L'écharpe de Mme Weasley.py
Normal file
24
L'écharpe de Mme Weasley.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from PIL import Image
|
||||
|
||||
image = Image.open("L'écharpe de Mme Weasley.png")
|
||||
#image = Image.open("L'écharpe de Mme Weasley_exemple.png")
|
||||
|
||||
block = 8
|
||||
|
||||
width, height = image.size
|
||||
|
||||
xmax = width // block
|
||||
ymax = height // block
|
||||
|
||||
res = ""
|
||||
|
||||
for x in range(xmax):
|
||||
for y in range(ymax):
|
||||
colors = {}
|
||||
for i in range(block):
|
||||
for j in range(block):
|
||||
pixel = image.getpixel((x*block+i,y*block+j))
|
||||
colors[pixel] = None
|
||||
res = res + f"{len(colors)-1:1X}"
|
||||
|
||||
print(bytearray.fromhex(res).decode())
|
||||
BIN
L'écharpe de Mme Weasley_exemple.png
Normal file
BIN
L'écharpe de Mme Weasley_exemple.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
14
Le retourneur de temps.py
Normal file
14
Le retourneur de temps.py
Normal file
@@ -0,0 +1,14 @@
|
||||
ctr = 0
|
||||
uctr = 0
|
||||
umax = uctr
|
||||
|
||||
while True:
|
||||
ctr = ctr + 1
|
||||
if ctr > 1 and sum([int(i) for i in str(uctr)])%7 == 0:
|
||||
uctr = uctr - 7
|
||||
else:
|
||||
uctr = uctr + 2
|
||||
|
||||
if uctr > umax:
|
||||
umax = uctr
|
||||
print("MAX = ", umax)
|
||||
54
Les cartes chocogrenouille à trier (1).py
Normal file
54
Les cartes chocogrenouille à trier (1).py
Normal file
@@ -0,0 +1,54 @@
|
||||
import requests
|
||||
import os
|
||||
import time
|
||||
|
||||
url_get = "https://pydefis.callicode.fr/defis/MLPotter01/intern/aMI7JVIH+mN1UYdaODx1mtD6QQVrpTvKjVyFbfcqBW9gwm1qWxv4LTI%3D/card.png"
|
||||
url_post = "https://pydefis.callicode.fr/defis/MLPotter01/intern/aMI7JVIH+mN1UYdaODx1mtD6QQVrpTvKjVyFbfcqBW9gwm1qWxv4LTI%3D/reponse"
|
||||
|
||||
card_folder = os.path.join(os.path.dirname(__file__), "chocogrenouille")
|
||||
|
||||
ctr = 0
|
||||
|
||||
#Preload already dopwnloaded cards
|
||||
cards = {}
|
||||
for (dirpath, dirnames, filenames) in os.walk(card_folder):
|
||||
for filename in filenames:
|
||||
with open(os.path.join(card_folder, filename), mode='rb') as file_obj:
|
||||
cards[file_obj.read()] = filename.replace(".png", "")
|
||||
break
|
||||
|
||||
while True:
|
||||
req_card = requests.get(url = url_get)
|
||||
|
||||
if req_card.content in cards:
|
||||
name = cards[req_card.content]
|
||||
found = True
|
||||
else:
|
||||
name = "unknown"
|
||||
found = False
|
||||
|
||||
req_res = requests.get(url = f"{url_post}/{name}")
|
||||
|
||||
response = req_res.content.decode("utf-8").strip().replace('"', '')
|
||||
|
||||
if "Password" in response:
|
||||
print(f"La reponse est: {response}")
|
||||
break
|
||||
|
||||
if found and response == name:
|
||||
ctr = ctr + 1
|
||||
print(f"J'ai bon: '{name}' ({ctr})")
|
||||
elif found:
|
||||
ctr = 0
|
||||
print(f"J'ai pas bon: '{response}' alors que j'avais prévu '{name}'")
|
||||
else:
|
||||
ctr = 0
|
||||
print(f"Un nouveau venu: '{response}'")
|
||||
|
||||
if not found:
|
||||
cards[req_card.content] = response
|
||||
with open(os.path.join(card_folder, response+".png"), "wb") as binary_file:
|
||||
# Write bytes to file
|
||||
binary_file.write(req_card.content)
|
||||
|
||||
time.sleep(1.1)
|
||||
34
Monnaie de sorcier.py
Normal file
34
Monnaie de sorcier.py
Normal file
@@ -0,0 +1,34 @@
|
||||
print("Exemple:")
|
||||
noises = 125*17*29
|
||||
|
||||
gallions = 125
|
||||
mornilles = gallions * 17
|
||||
noises = mornilles * 29
|
||||
|
||||
digits_noises = "".join(sorted(list({key:None for key in str(noises)}.keys())))
|
||||
digits_mornilles = "".join(sorted(list({key:None for key in str(mornilles)}.keys())))
|
||||
digits_gallions = "".join(sorted(list({key:None for key in str(gallions)}.keys())))
|
||||
|
||||
print("noises", noises)
|
||||
print("mornilles", mornilles)
|
||||
print("gallions", gallions)
|
||||
|
||||
|
||||
print("Maintenant, les choses sérieuses:")
|
||||
gallions = 1
|
||||
|
||||
while True:
|
||||
mornilles = gallions * 17
|
||||
noises = mornilles * 29
|
||||
|
||||
digits_noises = "".join(sorted(list({key:None for key in str(noises)}.keys())))
|
||||
digits_mornilles = "".join(sorted(list({key:None for key in str(mornilles)}.keys())))
|
||||
digits_gallions = "".join(sorted(list({key:None for key in str(gallions)}.keys())))
|
||||
|
||||
if digits_noises == digits_mornilles and digits_noises == digits_gallions:
|
||||
print("noises", noises)
|
||||
print("mornilles", mornilles)
|
||||
print("gallions", gallions)
|
||||
break
|
||||
|
||||
gallions = gallions + 1
|
||||
19
On a brouillé la carte du Maraudeur.py
Normal file
19
On a brouillé la carte du Maraudeur.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from PIL import Image
|
||||
|
||||
a = 53911
|
||||
b = 15677
|
||||
|
||||
image = Image.open("maraudeur_cr.png")
|
||||
|
||||
width, height = image.size
|
||||
res = Image.new(image.mode, (width, height))
|
||||
|
||||
n = width * height
|
||||
|
||||
for pos in range(n):
|
||||
new_pos = (a*pos+b)%n
|
||||
pixel = image.getpixel((new_pos%width,new_pos//width))
|
||||
res.putpixel((pos%width,pos//width), pixel)
|
||||
|
||||
#res.save("maraudeur_cr_res.png")
|
||||
res.show()
|
||||
BIN
maraudeur_cr.png
Normal file
BIN
maraudeur_cr.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.8 MiB |
Reference in New Issue
Block a user