\documentclass[11pt]{article}
\usepackage[margin=1in]{geometry}
\setlength{\parindent}{0pt}
\setlength{\parskip}{4pt}

% define styles for code listings
\usepackage[usenames,dvipsnames]{color}
\usepackage{listings}
\lstdefinestyle{cpp}{
    language=c++,%
    basicstyle=\tt\small,
    commentstyle=\color{Green},
    keywordstyle=\color{blue},
    stringstyle=\color{Orange},
    keepspaces=true,
    showstringspaces=false,
    tabsize=4
}
\lstdefinestyle{java}{
    language=java,%
    basicstyle=\tt\small,
    commentstyle=\color{Green},
    keywordstyle=\color{blue},
    stringstyle=\color{Orange},
    keepspaces=true,
    showstringspaces=false,
    tabsize=4
}

% customize pdf document properties
\usepackage[pdftex]{hyperref}
\hypersetup{%
  bookmarksopen=false,
  colorlinks=true,
  citecolor=black,
  filecolor=black,
  linkcolor=black,
  urlcolor=blue
}

%------------------------------------------------------------------------------%
\begin{document}
\vspace*{4em}

\hrule
\begin{center}
\LARGE
CS 280 Portfolio
\Large

\medskip
Chris Mayfield \\ mayfiecs@jmu.edu

\medskip
October 9, 2015
\end{center}
\hrule

\vspace*{2em}
\tableofcontents

%------------------------------------------------------------------------------%
\newpage

\vspace*{5em}
\begin{center}
\begin{Large}
\textbf{Submission Results}
\end{Large}

For each problem included in this portfolio, please state whether your solution is:

1. \textbf{Correct} ~ (accepted by UVa Online Judge or passes all \texttt{make trial} test cases)

2. \textbf{Selected} ~ (extra problems of your choice that were not part of weekly contests)
\end{center}

\begin{center}
\renewcommand{\arraystretch}{2}
\begin{tabular}{|c|c|c|c|}
\hline
\textbf{Number} & \textbf{Problem} & \textbf{Correct?} & \textbf{Selected?} \\
\hline
\hline
1 & ACM'12 A  & Yes & No \\
\hline
2 & UVa 10420 & Yes & No \\
\hline
3 & • & • & • \\
\hline
4 & • & • & • \\
\hline
5 & • & • & • \\
\hline
6 & • & • & • \\
\hline
7 & • & • & • \\
\hline
8 & • & • & • \\
\hline
9 & • & • & • \\
\hline
10 & • & • & • \\
\hline
\end{tabular}
\end{center}

%------------------------------------------------------------------------------%
\newpage
\section{Fifty Coats of Gray (Problem A, ICPC 2012)}

The point of this problem was to input several integers, make a simple calculation, and print the results on a single line. Given the dimensions of a room, including windows and doors, the program outputs how many cans of paint is necessary to cover the walls and ceiling. I decided to compute this total area while reading the input, rather than storing everything in an \texttt{ArrayList} and processing its contents later on.

One mistake I made while testing my solution was that I forgot to round the result up before printing it out. In addition, I forgot to include the area of the ceiling. It's important to read the problem statements carefully and write extra test cases!

\bigskip

\begin{lstlisting}[style=java]
/*
 * Fifty Coats of Gray (Problem A, ICPC 2012)
 *
 * Author: Chris Mayfield
 *   Date: 12/19/2012
 */

import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (true) {
            // read the next room
            int n = in.nextInt();
            int width = in.nextInt();
            int length = in.nextInt();
            int height = in.nextInt();
            int area = in.nextInt();
            int m = in.nextInt();

            // check stopping state
            if (n == 0 && width == 0 && length == 0 && height == 0
                && area == 0 && m == 0) {
                break;
            }

            // area of one room (4 walls and 1 ceiling)
            double room = 2 * width * height + 2 * length * height
                          + 1 * width * length;
            for (int i = 0; i < m; i++) {
                int x = in.nextInt();
                int y = in.nextInt();
                room -= x * y;
            }

            // compute the result
            System.out.println((int) Math.ceil(n * room / area));
        }
    }
}
\end{lstlisting}

%------------------------------------------------------------------------------%
\newpage
\section{List of Conquests (UVa 10420)}

This problem helped me learn how to use the C++ \texttt{map} container. It's amazing how you don't have to check whether the keys exist in the map before using them. I simply needed to read each name and increment its count in the map. My only issue with this program was that I did not appreciate how chauvinistic the story was!

\bigskip

\begin{lstlisting}[style=cpp]
/*
 * List of Conquests (UVa 10420)
 *
 * Author: Chris Mayfield
 *   Date: 02/01/2013
 */

#include <iostream>
#include <cstdio>
#include <map>

using namespace std;

// map names to counts
typedef map<string, int> map_si;
typedef map<string, int>::const_iterator itr_si;

int main()
{
    int lines;
    string name;
    string rest;
    map_si freqs;
    itr_si itr;

    // read the input
    cin >> lines;
    for (int i = 0; i < lines; i++)
    {
        cin >> name;
        getline(cin, rest);
        freqs[name]++;
    }

    // print the results
    for (itr = freqs.begin(); itr != freqs.end(); itr++)
    {
        printf("%s %d\n", itr->first.c_str(), itr->second);
    }
}
\end{lstlisting}

\end{document}
