Skip to content

Instantly share code, notes, and snippets.

View classes.py
print("BEFORE")
def creer_classes(eleves_tries):
taille_classe = len(eleves_tries)//3
return ( eleves_tries[:taille_classe],eleves_tries[taille_classe:2*taille_classe],eleves_tries[2*taille_classe:])
print(creer_classes([]))
print(creer_classes([0]))
print(creer_classes([0,1,2]))
@xcombelle
xcombelle / example.html
Last active July 31, 2023 16:25
une autre manière de faire un template
View example.html
[<!DOCTYPE html>]
[<html>]
for item in itemlist:
[<li>{item}</li>]
[</html>]
[<!-- tout ce qui se trouve entre crochet est ajouté au template, le reste s'execute come code executabel standard-->]
View risk.py
from itertools import product
dices=[range(1,7),range(1,7),range(1,7),range(1,7),range(1,7)]
wins={0:0,1:0,2:0}
C = 0
for a,b,c,d,e in product(*dices):
n=0;
d,e =sorted([d,e])
A,B = sorted([a,b,c],reverse=True)[:2]
if A>e:
View tes.txt
// Define the two rotations as quaternions
Quaternion rotation1 = Quaternion.Euler(x1, y1, z1); // First rotation
Quaternion rotation2 = Quaternion.Euler(x2, y2, z2); // Second rotation
// Combine the rotations
Quaternion combinedRotation = rotation1 * rotation2;
// Apply the combined rotation to the object's transform
transform.rotation = combinedRotation;
View asyouprefer.pseudocode
# pseudo code de ton traitement
################################
read_record:
for line in fichier():
records.append(scanf(line))
partie1:
for record in records():
@xcombelle
xcombelle / withmain.py
Last active May 8, 2023 07:57
global variable impact
View withmain.py
def main():
from time import time as t
t1=t()
for i in range(1_000_000_000):
@xcombelle
xcombelle / test.js
Last active April 13, 2023 14:49
random
View test.js
var win=0;for(var i=0;i<10*1000*1000;i++){if(Math.random()*100<=0.01){win++;};};console.log(win/(10*1000*1000));
View count.py
from collections import Counter
words = "le petit chat est mort le gros chien est rassasié".split()
count=Counter(words )
print(count.most_common())
# resultat
# [('le', 2), ('est', 2), ('petit', 1), ('chat', 1), ('mort', 1), ('gros', 1), ('chien', 1), ('rassasié', 1)]
@xcombelle
xcombelle / vaccum-maintenance.sh
Created August 15, 2019 08:20
This vaccum all database in the home directory
View vaccum-maintenance.sh
#!/bin/bash
set -eu
echo "Scanning for sqlite databases..."
find \
~\
-type f '(' -iname '*.sqlite' -o -iname '*.db' ')' \
-print0 | while read -r -d $'\0' filename; do
View mailman_pattern.py
import re
import sys
def e(arg):
return re.escape(arg)
def any(arg):
return "("+"|".join(map(re.escape,arg.split()))+")"
def non_space():
return r"\S+"
def spaced(*args):
return "\s+".join(args)