# Need macro to ignore specific even-numbered inputs

My document consists (among other things) of blocks that look like this:

\begin{Solution}{6.7.8,1.2.3}
...
\end{Solution}


or

\begin{Solution}{,1.2.3}
...
\end{Solution}


I would like to define the Solution environment so that, upon setting a switch, the contents of the block is included as is (with LaTeX processing, of course), or is omitted completely if the last digit (the "3" above) is even. In addition, the inserted text, if it is inserted, should be labeled with the full string ("1.2.3") in the above example. I don't know TeX well enough to even know where to start. Anyone willing to help?

-
What is the format of the argument to the Solution environment? Does it always contain just a single comma? What do the numbers represent? The more information you give, the easier it is to help. –  TH. Sep 13 '10 at 10:14
Yes, at most one comma. {x.y.z,a.b.c} means that the exercise was numbered x.y.z in the previous edition but is now numbered a.b.c. If x.y.z is not present (comma only), then a.b.c is a new exercise in this edition. –  rogerl Sep 13 '10 at 12:30

The solution to your question probably involves a number of three smaller subproblems:

1. Scanning the input argument to find the last number.
2. Testing whether a number is even or not.
3. Making (La)TeX ignore a block of code.

For the first one you probably need some TeX hackery, maybe something like this

\def\scan#1.#2.{\ifx#2\relax\def\next{#1}\else\def\next{\scan #2.}\fi\next}
\newcommand{\lastnumber}[1]{\scan#1.\relax.}


For the second task the ifthen package provides an \iffodd which might do the trick.

For the final and third task take a look at the verbatim package which, among other things, defines a comment environment to ignore blocks of LaTeX code.

-