Automate A Pile Exercices Corriges Patched -
pdflatex pile_exercices.tex # with corrections # Change \correctionfalse to hide solutions
L'élève doit comprendre que l'automate empêche la division par zéro et le sous-remplissage.
\documentclassarticle \usepackageamsmath, amssymb \usepackagetcolorbox automate a pile exercices corriges
def eval_postfix(expression): stack = [] tokens = expression.split() for t in tokens: if t.isdigit(): stack.append(int(t)) elif t in '+-*/': if len(stack) < 2: return "Erreur : pas assez d'opérandes" b = stack.pop() a = stack.pop() if t == '+': stack.append(a + b) elif t == '-': stack.append(a - b) elif t == '*': stack.append(a * b) elif t == '/': stack.append(a // b) else: return f"Caractère invalide: t" return stack[0] if len(stack) == 1 else "Erreur: expression mal formée"
Create one LaTeX file that includes all exercises and their corrections, toggleable with a single flag. pdflatex pile_exercices
, pop one symbol from the stack. If the stack is empty exactly when the input ends, the word is valid. : ' seen, push ' 's, continue pushing ' ' seen, pop ' ', switch to state 's, keep popping ' (Input finished, stack back to Z0cap Z sub 0 , accept). Exercise B: Palindromes (
#!/bin/bash mkdir -p pile_exercices pile_corriges If the stack is empty exactly when the
| Need | Solution | |------|----------| | Generate many exercises from a table | Python + CSV | | Rename/organize existing exercise/correction files | Bash script | | Professional printable PDF with toggleable solutions | LaTeX |
if [[ -f "$cor_file" ]]; then mv "$ex_file" pile_exercices/exercice_$num.md mv "$cor_file" pile_corriges/corrige_$num.md echo "Paired exercise $num" else echo "Missing correction for $num" fi
: Elles dépendent de l'état actuel, du caractère lu, et du sommet de la pile. Critères d'acceptation : Un automate peut accepter par état final Déterminisme