I made a package just for purposes like this. It's called exercisebank
.
Say you have your 2017.tex
, and in there you should have puzzles and solutions in the following format.
%% 2017.tex
%% Heads up! \end{solution} and \end{problem} can't have spaces in front of it and needs it's own line
\begin{problem}
Puzzle 1 here
\end{problem}
\begin{solution}
Solution 1 here
\end{solution}
\begin{problem}
Puzzle 2 here
\end{problem}
\begin{solution}
Solution 2 here
\end{solution}
Now you can do
\documentclass{article}
\usepackage{exercisebank}
% You might want no part problem headers (only Problem 1, Problem 2 etc), in that case: uncomment the line below:
% \exercisebanksetup{part problems=Off}
% To make a setup, you do this; \makeset{setupName}{puzzle-file}
% So to make a setup with all of the exercises from 2017:
\makeset{allof2017}{2017}
% Or you can cherry pick your favorites
\makeset{2017Favorites}{\select{2017}{1,2}}
\begin{document}
% Then choose which to build
\buildset{2017Favorites}
\end{document}
If you end up using this, please feel free to request features or report bugs here
Edit: I've now come across some other packages that do similar things. So I should also mention that e.g. xsim
might also do what you want, and is probably more stable at this time. Furthermore, you could check out the exercise
and exam
topics on CTAN.