Skip to content

Instantly share code, notes, and snippets.

from random import shuffle
# Il manque forcément des gens
participants = ["Ambre", "Arthur", "Théo", "Jeanne", "Gawry", "Antoine", "Océane", "Lisa", "Éloi", "Maëlyse"]
cadeau_a = participants.copy()
while any(p == c for p, c in zip(participants, cadeau_a)):
shuffle(cadeau_a)
for p, c in zip(participants, cadeau_a):
@eloidrai
eloidrai / sudoku.c
Last active March 7, 2023 07:44
Solveur de sudoku par backtracking
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
int grille[81] = {0};
void init (FILE * file, int * grille) {
for (int i = 0; i<81; i++) {
char c = fgetc(file);
if (c == '\n') c = fgetc(file);
from collections import defaultdict
def generer_tableau(mot):
d = defaultdict(lambda : -1)
for i in range(len(mot)):
for j in range(i+1, len(mot)):
d[(mot[i], j)] = i
return d
def boyer_moore(t, m):
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#include <stdio.h>
#include <stdlib.h>
#define TABSIZE 1000
void print_array(int * array, int size) {
for (int i=0; i<size; i++) {
printf("%d ", array[i]);
}
puts("");
@eloidrai
eloidrai / quine.hs
Last active October 2, 2022 22:14
L'algorithme de Quine pour savoir si une formule est satifiable.
{-# LANGUAGE InstanceSigs #-}
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
{-# LANGUAGE StrictData #-}
module Quine where
import Data.Maybe ( fromJust )
-- Propositional calculus
data Formula = Top | Bottom | P !Integer | Disjunction !Formula !Formula | Conjunction !Formula !Formula | Negation !Formula
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import System.Environment
import Data.Char
execute :: String -> String -> Int -> Int -> IO ()
execute instructionArray dataArray instructionPointer dataPointer
| (instructionPointer < 0 || dataPointer < 0) = fail "Negative index !"
| (instructionPointer >= length instructionArray) = return ()
| otherwise = case (instructionArray !! instructionPointer) of
'>' -> execute instructionArray dataArray (instructionPointer+1) (dataPointer+1)
'<' -> execute instructionArray dataArray (instructionPointer+1) (dataPointer-1)
@eloidrai
eloidrai / Makefile
Created September 6, 2021 17:02
Une implémentation du jeu de la vie en C avec la SDL
main: main.c
gcc -o $@ $^ `sdl2-config --cflags --libs`