\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{cs1570}[2023/08/01 CS 1570 LaTeX class]

\LoadClass[11pt]{article}
\RequirePackage[margin=1in, headheight=14pt]{geometry}
\RequirePackage{amsmath}
\RequirePackage{amssymb}
\RequirePackage{amsthm}
\RequirePackage{graphicx}
\RequirePackage{fancyhdr}
\RequirePackage{titling}
\RequirePackage{etoolbox}
\RequirePackage{framed}
\RequirePackage{xcolor}
\RequirePackage{algorithm}
\RequirePackage{algpseudocodex}
\RequirePackage{bold-extra}
\RequirePackage{hyperref}
\RequirePackage{enumerate}
\RequirePackage{physics}
\RequirePackage{multirow}
\RequirePackage{booktabs}

\definecolor{shadecolor}{gray}{0.8}


%%% Header, footer, and title customization
\renewcommand{\footrulewidth}{1pt}
\fancypagestyle{plain}{
    \fancyhead[L]{\textbf{CSCI1570}}
    \fancyhead[C]{Design and Analysis of Algorithms}
    \fancyhead[R]{\textbf{Lorenzo De Stefani}}
    \fancyfoot[L]{\documentName}
    \fancyfoot[R]{Fall 2023}
}
\pagestyle{plain}

\renewcommand{\author}{\PackageError{cs1570}{Don't write your name on the assignment !}}
% Leave the argument empty ({}) to remove the due date
\newcommand{\due}{\date}

\setlength{\droptitle}{-4em}
\renewcommand{\maketitle}{\begin{center}\huge\textbf{\@title}\\\vspace{0.5em}\Large\ifdefempty{\@date}{}{Due: \@date}\end{center}}

%%% Convenience Commands
\newcommand{\hwk}[3]{%
    \newcommand{\assignmentNumber}{#1}
    \newcommand{\documentName}{#2}
    \title{Homework \assignmentNumber: \documentName}
    \due{#3}
}

\newcommand{\sol}[2]{%
    \newcommand{\assignmentNumber}{#1}
    \newcommand{\documentName}{#2}
    \title{Solution \assignmentNumber: \documentName}
    \due{}
}

\newcommand{\guide}[1]{%
    \newcommand{\documentName}{#1}
    \title{#1}
    \due{}
}

\newcommand{\assignmentInstructions}{%
    \setlength{\parindent}{0pt}
    This homework must be typed in \LaTeX\ and submitted via Gradescope.

    \medskip

    Please ensure that your solutions are complete, concise, and communicated clearly. Use full sentences and plan your presentation before your write. Except where indicated, consider every problem as asking for a proof.
}

\newcounter{problemCounter}
\newenvironment{problem}[1][]{\begin{shaded}\refstepcounter{problemCounter}\par\medskip
        \noindent \textbf{Problem~\theproblemCounter. #1}}{\end{shaded}\medskip}

\newenvironment{solution}{\begin{proof}[Solution]}{\end{proof}}

% Pseudocode
\newcommand{\chigh}[2]{%
    \BeginBox[fill=#1]
    #2
    \EndBox
}

\newcommand{\cstring}[2]{%
    \BoxedString[fill=#1]{#2}
}

\newcommand{\Input}{\Require}

\renewcommand{\Output}{\Ensure}

\algrenewcommand\algorithmicrequire{\textbf{Input:}}
\algrenewcommand\algorithmicensure{\textbf{Output:}}

\makeatletter
\preto{\@verbatim}{\topsep=0pt \partopsep=0pt}
\algrenewcommand\ALG@beginalgorithmic{\ttfamily}
\makeatother