\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{gtiassn}

\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions\relax

\LoadClass[11pt, letterpaper]{article}

\RequirePackage{fullpage}

\usepackage{enumerate}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amstext}
\usepackage{amscd}
\usepackage{amsmath}
\usepackage{xspace}
\usepackage{theorem}
\usepackage{float}
\usepackage{graphicx}
\usepackage{ifthen}
\usepackage{versions}
\usepackage{calc}

\renewcommand{\familydefault}{\sfdefault}

\RequirePackage[usenames]{color}

\setlength{\textwidth}{6.5in}
\setlength{\oddsidemargin}{0in}
\setlength{\evensidemargin}{0in}
\setlength{\topmargin}{-.25in}
\setlength{\textheight}{9in}
\setlength{\headheight}{0pt}
\setlength{\headsep}{0pt}
\setlength{\marginparwidth}{59pt}

\setlength{\parindent}{0pt}
\setlength{\parskip}{5pt plus 1pt}
\setlength{\abovedisplayskip}{8pt plus 3pt minus 6pt}
\setlength{\intextsep}{15pt plus 3pt minus 6pt}

\renewcommand{\section}{\@startsection{section}{1}{0mm}%
                                  {2ex plus -1ex minus -.2ex}%
                                  {0.1ex plus .2ex}%
                                  {\normalfont\Large\bfseries}}%

%
% Default parameter values
%

\newcommand{\TheDueDate}{Katilsday, February 31}
\newcommand{\TheNumber}{$-\infty$}
\newcommand{\TheDirections}{Write up carefully argued solutions to the 
following problems. The first task is to be complete and correct. The more 
subtle task is to keep it simple and succinct. Your solution should be 
clear enough that it should explain to someone who does not already 
understand the answer why it works. You may use any results proven in 
lecture without proof. Anything else must be argued rigorously.  Unless 
otherwise specified, all answers are expected to be given in closed form.}

\newcommand{\gtidate}[1]{\renewcommand{\TheDueDate}{#1}}
\newcommand{\gtinumber}[1]{\renewcommand{\TheNumber}{#1}}
\newcommand{\directions}[1]{\renewcommand{\TheDirections}{#1}}
\renewcommand{\labelenumi}{(\alph{enumi})}

\definecolor{maroon}{rgb}{.6902,.0078,.0039}

%
% Make the homework header
%

%%%%%%%%%%%%%%%%%% Toggling of document types %%%%%%%%%%%%%%%%%%%%%%
\newcommand{\ifthen}[2]{\ifthenelse{#1}{#2}{}}

\newcommand{\TheType}{Document}
\newcommand{\TheFlavorA}{}
\newcommand{\TheFlavorB}{}
\newboolean{ShowNumbers}
\setboolean{ShowNumbers}{true}
\newboolean{ShowPoints}
\setboolean{ShowPoints}{true}
\newboolean{ShowSolutions}
\setboolean{ShowSolutions}{false}
\newboolean{ShowDate}
\setboolean{ShowDate}{true}
\newboolean{ShowDirections}
\setboolean{ShowDirections}{true}
\newboolean{OnlyWarmup}
\setboolean{OnlyWarmup}{false}

\newcommand{\showNumbers}{\setboolean{ShowNumbers}{true}}
\newcommand{\hideNumbers}{\setboolean{ShowNumbers}{false}}
\newcommand{\showPoints}{\setboolean{ShowPoints}{true}}
\newcommand{\hidePoints}{\setboolean{ShowPoints}{false}}
\newcommand{\showDate}{\setboolean{ShowDate}{true}}
\newcommand{\hideDate}{\setboolean{ShowDate}{false}}
\newcommand{\showDirections}{\setboolean{ShowDirections}{true}}
\newcommand{\hideDirections}{\setboolean{ShowDirections}{false}}

\newcommand{\homework}{
    \showNumbers
    \showPoints
    \showDate
    \showDirections
    \renewcommand{\TheType}{Homework}
}
\newcommand{\recitation}{
    \hideNumbers
    \hidePoints
    \hideDate
    \hideDirections
    \renewcommand{\TheType}{Recitation}
}

\newcommand{\warmup}{
    \hideDate
    \setboolean{OnlyWarmup}{true}
    \renewcommand{\TheFlavorA}{ Warmup}
    \let\question\comment %Everything from the question environment should
                          %be suppressed, because they are all normal
                          %questions
}

\newcommand{\solutions}{
    \hideDirections
    \hideDate
    \setboolean{ShowSolutions}{true}
    \renewcommand{\TheFlavorB}{ Solutions}
}

\newcommand{\solution}[1]{%
    \ifthen{\boolean{ShowSolutions}}{%
        \vspace{-1.25ex}%
        \begin{indented}%
        \fbox{\begin{minipage}[c]{\linewidth}#1\end{minipage}}%
        \end{indented}%
    }%
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\MakeHeader}[3]{

{\color{maroon} {\noindent \Large 
\textbf{\textsf{15-251: Great Theoretical Ideas In Computer Science}}
} \vspace{-1ex} \\ \rule[1mm]{\textwidth}{.3mm} \\
{\Large \noindent \textbf{\textsf{\TheType\;#1\TheFlavorA\TheFlavorB
    \ifthen{\boolean{ShowDate}}{ (due #2)}}}} \\
}\\ \ifthen{\boolean{ShowDirections}}{ 
\textsf{{\bf Directions}:{\sl#3}\\\\}}
\vspace{-3ex}
}

%
% Make the section headers
%

\newcounter{TheQuestionNumber}
\newcounter{ThePartNumber}[TheQuestionNumber]

\newenvironment{question-base}[2]{
    \vspace{-3ex}
    \textbf{
        \textsf{
            \section*{\color{maroon}% 
                \ifthen{\boolean{ShowNumbers}}%
                       {\arabic{TheQuestionNumber}.}#1
                \ifthen{\boolean{ShowPoints}}{(#2 points)}}%
                \addtocounter{TheQuestionNumber}{1}%
                \setcounter{ThePartNumber}{0}%
}}}

\newenvironment{warmup-question}{
    \begin{question-base}{Warmup}{0}
}{
    \end{question-base}
}

\newenvironment{question}[2]{%
    \begin{question-base}{#1}{#2}%
}{
    \end{question-base}
}

\def\indented#1{\list{}{}\item[]}
\let\indented=\endlist 

\renewenvironment{part}[1]{
    \addtocounter{ThePartNumber}{1}
    \begin{indented}
    \begin{enumerate}[(\alph{ThePartNumber})]
        \item\ifthen{\boolean{ShowPoints}}{[{#1} Points]}
}{\end{enumerate}\end{indented}}

\AtBeginDocument{\MakeHeader{\TheNumber}{\TheDueDate}{\TheDirections}}
