% --------------- identification ----------------
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{PNSProblem}[2003/02/16]
% --------------- initial code ---------------
% --------------- declaration of options ---------------
% --------------- execution of options ---------------
% --------------- package loading ---------------
% --------------- main code ---------------


%%%%%%%%%%%%%%%%%%%%%%%
%                     %
%   Pedagogic stuff   %
%                     %
%%%%%%%%%%%%%%%%%%%%%%%

\newenvironment{example}[1]{
  \begin{list}{}%
	 {\setlength{\labelsep}{0pt}%
	 \setlength{\leftmargin}{.3in}%
	 \setlength{\rightmargin}{\leftmargin}%
	 \setlength{\labelwidth}{0pt}%
	 \setlength{\listparindent}{0pt}}%
	 \item[\umph{Example:}] \mbox{\quad}
	 \colorbox{yellow}{\umph{#1}}
	 \\[.1in]
	 }%
	 {\end{list}
	 
	 \hfill{\color{yellow}\rule{4.5in}{.05in}}\hfill
	 }

\newcounter{problemctr}  		% in the book format, this is linked
								% to [chapter]

\newboolean{compactproblems}	% save space in lists of parts of problem
\setboolean{compactproblems}{false}

\newcommand{\theproblem}{}
\newcounter{difficultylevel}
\newcounter{problemparts}

\newcommand{\toughness}{\ding{45}}
\newboolean{iscomputerproblem}
\setboolean{iscomputerproblem}{false}
\newcommand{\icongap}{\hspace{.5em}}

\newcommand{\difficulty}[1]{%
   \ifthenelse{\equal{#1}{1}}{\toughness}{%
      \ifthenelse{\equal{#1}{2}}%
	  	{\toughness\toughness}%
        {\toughness\toughness\toughness}%
	}\hspace{0.5em}%
}

\newcommand{\theexercise}{}

\newenvironment{exercise}
  {\refstepcounter{problemctr}%
  \renewcommand{\theexercise}{\arabic{problemctr}}%
  \begin{list}{\umph{Exercise \theexercise}}%
	 {\setlength{\labelsep}{0pt}%
	 \setlength{\leftmargin}{.2in}%
	 \setlength{\labelwidth}{0pt}%
	 \setlength{\listparindent}{0pt}}%
	 \item\ ~}%
	 {\end{list}}

\newenvironment{parts}{}{}

\newenvironment{problem}[1][]
  {\begingroup\refstepcounter{problemctr}%
  \ifthenelse{\boolean{compactproblems}}%
  	{\renewenvironment{parts}{%
		\setcounter{problemparts}{0}%
		 \def\item{\nobreak\ignorespaces\stepcounter{problemparts}%
		 \hspace{.25em}(\alph{problemparts})~}%
		}{\par}%
	}%  end of this version of parts environment
	{\renewenvironment{parts}{%
		\setcounter{problemparts}{0}%
		\begin{list}{%  What follows is the default label code
			\stepcounter{problemparts}%
			(\alph{problemparts})~%
			}%
			{\setlength{\leftmargin}{.35in}% parameter setup
			\setlength{\labelwidth}{2em}%
			}%
		}% end of the first argument of the parts environment
		{\end{list}} % at end of the parts environment
	}% end of second definition of parts environment
  \renewcommand{\theexercise}{\arabic{problemctr}}%
% \ifthenelse{\boolean{iscomputerproblem}}{%
% \makebox[0pt][r]{\ding{39}\icongap}}{}%
  \begin{list}{\umph{Problem \theexercise}}%
	 {\setlength{\labelsep}{0pt}%
	 \setlength{\leftmargin}{0in}%
	 \setlength{\labelwidth}{0pt}%
	 \setlength{\listparindent}{0pt}}%
	 \item%
	 \ifthenelse{\equal{#1}{}}{}{\umph{ -- #1}}
	 \icongap%
     \ifthenelse{\boolean{iscomputerproblem}}{%
	 %\ding{39}\icongap%
	 \ig[.2]{computer}\icongap
	 }{}
}%
	 {\end{list}\endgroup%
}

\newboolean{solutions}
\setboolean{solutions}{true}
\newcommand{\ifsols}[2][Solution:]{\ifthenelse{\boolean{solutions}}%
	{\ifthenelse{\equal{#1}{}}%
		{}%
		{\smallskip\umph{#1}}#2}%
    {}}
\newcommand{\nosol}[1]{\ifthenelse{\boolean{solutions}}{}{#1}}
\newcommand{\yessol}[1]{\ifthenelse{\boolean{solutions}}{#1}{}}

\newcommand{\src}[1]{(\textmd{\textsl{#1}})}
\newcommand{\pg}{\bigskip}		% problem gap
\newcommand{\qed}{\ensuremath{\hfill\blacksquare}}

