Latest news 2024-07-03: Ebook sale (1st – 31st July 2024): short story cybercrime fiction Unsocial Media free; short story cybercrime fiction Smile for the Camera free; short story noir crime fiction I’ve Heard the Mermaid Sing free; crime fiction novel The Private Enemy US$1.99; illustrated children’s story The Foolish Hedgehog US$0.99.

Random selection with pgfmath.sty and probsoln.sty

\documentclass{article}

\usepackage{pgfmath}
\usepackage{probsoln}

% set random seed
\pgfmathsetseed{\year}

\begin{defproblem}{easy.diff}%
\ifundef\easydiffcoeff
{%
\pgfmathrandominteger{\easydiffcoeff}{2}{10}% generate random coefficient
\global\let\easydiffcoeff\easydiffcoeff % make it global
}
\begin{onlyproblem}
% question
Differentiate with respect to $x$:
$y = \sin(\easydiffcoeff x)$
\end{onlyproblem}
\begin{onlysolution}
% solution
$y' = \easydiffcoeff\cos(\easydiffcoeff x)$
\end{onlysolution}
\end{defproblem}

\begin{document}

\section{Questions}

\begin{enumerate}
\foreachproblem{\item\thisproblem}
\end{enumerate}