\documentclass[a4paper,11pt]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[french]{babel}
\usepackage[a4paper,top=3.2cm,bottom=2cm,left=2cm,right=2cm]{geometry}
\usepackage{graphicx}
\usepackage[export]{adjustbox}
\usepackage{fancyhdr}
\usepackage{qrcode}
\usepackage[table]{xcolor}
\usepackage{amsmath,amssymb}
\usepackage{enumitem}
% Puces nettes (babel-french remplace sinon la puce par un tiret « – » peu pro).
% Vaut pour TOUTES les fiches qui importent ce module. AtBeginDocument pour
% passer après la personnalisation des listes faite par babel-french.
\AtBeginDocument{%
  \setlist[itemize]{leftmargin=1.8em,itemsep=0.5ex,topsep=0.4ex,parsep=0pt}%
  \setlist[itemize,1]{label=\textcolor{red!75!black}{\small\textbullet}}%
  \setlist[itemize,2]{label=\textcolor{red!75!black}{\scriptsize\textbullet}}%
}
% Titres compacts (gain de place vertical, fiches plus denses) — vaut pour tous.
\usepackage{titlesec}
\titlespacing*{\section}{0pt}{1.4ex}{0.6ex}
\titlespacing*{\subsection}{0pt}{1.0ex}{0.3ex}
% multicol : listes denses (calcul mental) sur 2 colonnes — neutre tant qu'il
% n'est pas utilisé, dispo pour tous les générateurs.
\usepackage{multicol}
\setlength{\columnsep}{1.5em}
% needspace : empêche un titre d'exercice de rester orphelin en bas de page
% (réserve quelques lignes ; sinon le titre passe à la page suivante avec sa
% liste). Neutre tant qu'il n'est pas appelé — dispo pour tous les générateurs.
\usepackage{needspace}
\usepackage{tikz}
\usetikzlibrary{decorations.text}

\usepackage{tgheros}
\pagestyle{fancy}
\fancyhf{}
\setlength{\headheight}{75pt}
\setlength{\headsep}{10pt}

\newcommand{\logowouf}{%
\begin{tikzpicture}[baseline={(current bounding box.center)},scale=0.55,
                    line cap=round,line join=round]
    \path[use as bounding box] (-2.20,-1.45) rectangle (2.20,2.20);
    \path[
        postaction={decorate},
        decoration={
            text along path,
            text={|\fontfamily{qhv}\bfseries\fontsize{9}{9}\selectfont|site2wouf.fr},
            text align={center},
            raise=0.03ex
        }
    ] (-1.29,0.48) arc[start angle=160,end angle=20,radius=1.29];
    \begin{scope}[xshift=-0.06cm]
        \fill[black] (-0.66,0.14) ellipse (0.21 and 0.31);
        \fill[black] ( 0.66,0.14) ellipse (0.21 and 0.31);
        \fill[black] (-0.23,0.49) ellipse (0.22 and 0.35);
        \fill[black] ( 0.23,0.49) ellipse (0.22 and 0.35);
        \fill[black]
            (0,-0.10)
            .. controls (-0.36,-0.02) and (-0.63,-0.24) .. (-0.58,-0.58)
            .. controls (-0.52,-0.93) and (-0.16,-1.12) .. (0,-0.90)
            .. controls (0.16,-1.12) and (0.52,-0.93) .. (0.58,-0.58)
            .. controls (0.63,-0.24) and (0.36,-0.02) .. (0,-0.10)
            -- cycle;
    \end{scope}
\end{tikzpicture}%
}

\definecolor{ampon}{HTML}{FFE082}
\definecolor{ampbase}{HTML}{9E9E9E}
\definecolor{swbody}{HTML}{E8E6D9}
\definecolor{swgreen}{HTML}{5FA017}
% \ampoule{x}{y}{numéro}{couleur du verre}
\newcommand{\ampoule}[4]{%
  \begin{scope}[shift={(#1,#2)}]
    \fill[#4] (0,0.72) circle (0.52);
    \draw[black,line width=0.9pt] (0,0.72) circle (0.52);
    \fill[ampbase] (-0.30,0.05) -- (0.30,0.05) -- (0.24,0.24) -- (-0.24,0.24) -- cycle;
    \draw[black,line width=0.7pt] (-0.30,0.05) -- (0.30,0.05) -- (0.24,0.24) -- (-0.24,0.24) -- cycle;
    \fill[ampbase] (-0.24,-0.14) rectangle (0.24,0.05);
    \draw[black,line width=0.7pt] (-0.24,-0.14) rectangle (0.24,0.05);
    \draw[black,line width=0.5pt] (-0.24,-0.04)--(0.24,-0.04);
    \node[black,font=\bfseries\footnotesize] at (0,0.74) {#3};
  \end{scope}}
% \interrupteur{x}{y}{numéro}
\newcommand{\interrupteur}[3]{%
  \begin{scope}[shift={(#1,#2)}]
    \fill[swbody,rounded corners=2pt] (-0.62,-0.78) rectangle (0.62,0.78);
    \draw[black,line width=1pt,rounded corners=2pt] (-0.62,-0.78) rectangle (0.62,0.78);
    \foreach \sx in {-0.44,0.44}\foreach \sy in {-0.58,0.58}{%
      \fill[black!25] (\sx,\sy) circle (0.08);
      \draw[black,line width=0.4pt] (\sx,\sy) circle (0.08);}
    \fill[swgreen,rounded corners=1.5pt] (-0.30,-0.46) rectangle (0.30,0.46);
    \draw[black,line width=0.7pt,rounded corners=1.5pt] (-0.30,-0.46) rectangle (0.30,0.46);
    \node[white,font=\bfseries\small] at (0,0) {#3};
  \end{scope}}

\newcommand{\titre}{Les ampoules}
\newcommand{\soustitre}{Casse-tête des multiples : interrupteurs et changements d'état}

\fancyhead[C]{%
\raisebox{4pt}{%
\begin{minipage}[c]{0.15\textwidth}
    \centering
    \logowouf
\end{minipage}
\begin{minipage}[c]{0.62\textwidth}
    \centering
    {\Large\bfseries \titre\par}
    {\small\color{gray} \soustitre}
\end{minipage}
\begin{minipage}[c]{0.21\textwidth}
    \centering
    \qrcode[height=1.5cm]{https://site2wouf.fr/ampoules.php?x=20}\\[2pt]
    {\small\ttfamily\bfseries\color{red} AMPO0020}
\end{minipage}%
}
}

\begin{document}

\begin{center}
    \small On appuie sur les 4 interrupteurs. Chaque interrupteur n bascule l'état (allumée\,$\leftrightarrow$\,éteinte) des ampoules dont le numéro est un multiple de n. Quelles ampoules sont allumées à la fin ?
\end{center}
\vspace{0.5em}
\begin{center}\textbf{Les 12 ampoules} (certaines allumées) :\end{center}
\begin{center}\begin{tikzpicture}
\ampoule{-4.62}{0.00}{158}{white}
\ampoule{-2.77}{0.00}{192}{ampon}
\ampoule{-0.92}{0.00}{246}{white}
\ampoule{0.93}{0.00}{414}{ampon}
\ampoule{2.78}{0.00}{450}{ampon}
\ampoule{4.62}{0.00}{690}{ampon}
\ampoule{-4.62}{-2.15}{720}{ampon}
\ampoule{-2.77}{-2.15}{795}{white}
\ampoule{-0.92}{-2.15}{846}{white}
\ampoule{0.93}{-2.15}{887}{white}
\ampoule{2.78}{-2.15}{906}{white}
\ampoule{4.62}{-2.15}{926}{ampon}
\end{tikzpicture}\end{center}
\begin{center}\textbf{Les 4 interrupteurs} :\end{center}
\begin{center}\begin{tikzpicture}
\interrupteur{-3.00}{0}{2}
\interrupteur{-1.00}{0}{5}
\interrupteur{1.00}{0}{6}
\interrupteur{3.00}{0}{9}
\end{tikzpicture}\end{center}

\newpage
{\Large\bfseries\color{red} Correction}\par\medskip
État final des ampoules après les 4 appuis :\par\medskip
\begin{center}\begin{tikzpicture}
\ampoule{-4.62}{0.00}{158}{ampon}
\ampoule{-2.77}{0.00}{192}{ampon}
\ampoule{-0.92}{0.00}{246}{white}
\ampoule{0.93}{0.00}{414}{white}
\ampoule{2.78}{0.00}{450}{ampon}
\ampoule{4.62}{0.00}{690}{white}
\ampoule{-4.62}{-2.15}{720}{ampon}
\ampoule{-2.77}{-2.15}{795}{ampon}
\ampoule{-0.92}{-2.15}{846}{ampon}
\ampoule{0.93}{-2.15}{887}{white}
\ampoule{2.78}{-2.15}{906}{white}
\ampoule{4.62}{-2.15}{926}{white}
\end{tikzpicture}\end{center}
\medskip\par\textbf{Ampoules allumées :} 158, 192, 450, 720, 795, 846.

\end{document}
