\documentclass[addpoints]{exam}
\usepackage[utf8]{inputenc}
\usepackage{ragged2e}
\usepackage[unboxed]{cwpuzzle}

\usepackage{pifont}
\usepackage{pythonhighlight}
\usepackage{listings}
\usepackage{graphicx} % allow embedded images
  \setkeys{Gin}{width=\linewidth,totalheight=\textheight,keepaspectratio}
  \graphicspath{{graphics/}} % set of paths to search for images

\usepackage{hhline} 
\usepackage[math]{cellspace}
\cellspacetoplimit 1.25em
\cellspacebottomlimit 1.25em

\usepackage{multicol}

%%% Custom Vars

\newcommand{\slant}[2]{\,{}^{#1}{\mskip -5mu/\mskip -3mu}_{#2}}
\newcommand{\markForDrop}{{\large\color{red}\textdagger}}
\newcommand{\HorRule}[2][black]{%
	{\color{#1} \centerline{\rule{\linewidth}{#2pt}}}%
}
\newcommand{\HorRuleScaled}[3][black]{%
	{\color{#1} \centerline{\rule{#3\linewidth}{#2pt}}}%
}

%% Defaults
\providecommand{\courselabel}{LS40}
\providecommand{\extitle}{Exam}
\providecommand{\exyear}{\the\year{}}

% Preamble Template Insertion Point %

\pagestyle{headandfoot}

% \rhead{\makebox[0.2\textwidth]{Initials:\enspace\hrulefill}\hspace{0.1\textwidth}}
\rhead{}
% \lhead{\studentname}
\lhead{}
\chead{\courselabel{}: \extitle{}}
\lfoot{\courselabel{}: \exyear{}}
\rfoot{Page \thepage}
\cfoot{}

% special colors
\definecolor[named]{UCLABlue}{hsb:rgb/cmyk}{0.1961,0.5176,0.749/0.75,0.35,0,0.07}
\definecolor[named]{UCLAYellow}{hsb:rgb/cmyk}{1,0.9098,0/0,0.05,1,0}
\definecolor[named]{UCLALtBlue}{hsb:rgb/cmyk}{0,0.6471,0.8980/0.9,0.1,0,0}
\definecolor[named]{UCLADkBlue}{hsb:rgb/cmyk}{0,0.3333,0.651/1,0.75,0,0}
\definecolor[named]{UCLAgr}{hsb:rgb/cmyk}{0.9961,0.7333,0.2118/0,0.22,0.93,0}
\definecolor[named]{UCLAng}{hsb:rgb/cmyk}{0,1,0.5294/0.75,0,0.9,0}
\definecolor[named]{UCLAnpur}{hsb:rgb/cmyk}{0.5098,0.2157,1/0.7,0.75,0,0}
\definecolor[named]{UCLAnpin}{hsb:rgb/cmyk}{1,0,0.6484/0,1,0,0}
\definecolor[named]{UCLAGold}{hsb:rgb/cmyk}{0.99609,0.734375,0.21484/0,0.22,0.93,0}
% special colors
\definecolor[named]{cPurple}{HTML}{9469AD}
\definecolor[named]{cBlue}{HTML}{88C9C1}
\definecolor[named]{cOrange}{HTML}{F79A52}
\definecolor[named]{cRed}{HTML}{E04B4B}
\definecolor[named]{cGreen}{HTML}{73B55B}
\definecolor[named]{cGrey}{HTML}{D2D2D2}
\definecolor[named]{cGrey2}{HTML}{A6A6A6}
\definecolor[named]{cSatBlue}{HTML}{4682B4}

\definecolor[named]{cPurple}{HTML}{9469AD}
\definecolor[named]{cBlue}{HTML}{88C9C1}
\definecolor[named]{cOrange}{HTML}{F79A52}
\definecolor[named]{cRed}{HTML}{E04B4B}
\definecolor[named]{cGreen}{HTML}{73B55B}
\definecolor[named]{cGrey}{HTML}{D2D2D2}
\definecolor[named]{cGrey2}{HTML}{A6A6A6}
\definecolor[named]{cSatBlue}{HTML}{4682B4}


% Override from pythonhighlight package (uses listings package)
\colorlet{keywordcolour}{UCLABlue}
\colorlet{literatecolour}{UCLAnpin}
\definecolor{maroon}{cmyk}{0, 0.87, 0.68, 0.32}
\definecolor{halfgray}{gray}{0.55}
\definecolor{ipython_frame}{RGB}{207, 207, 207}
\definecolor{ipython_bg}{RGB}{247, 247, 247}
\definecolor{ipython_red}{RGB}{186, 33, 33}
\definecolor{ipython_green}{RGB}{0, 128, 0}
\definecolor{ipython_cyan}{RGB}{64, 128, 128}
\definecolor{ipython_purple}{RGB}{170, 34, 255}

\lstset{%
	basicstyle=\ttfamily\footnotesize,%
	escapeinside={||},%
	mathescape=true,
	numbers=left,                   % where to put the line-numbers
	numberstyle=\tiny\color{gray},  % the style that is used for the line-numbers
	stepnumber=1,                   % the step between two line-numbers. If it's 1, each line
	                                % will be numbered
	numbersep=5pt,                  % how far the line-numbers are from the code
	backgroundcolor=\color{WhiteSmoke},  % choose the background color. You must add \usepackage{color}
	showspaces=false,               % show spaces adding particular underscores
	showstringspaces=false,         % underline spaces within strings
	showtabs=false,                 % show tabs within strings adding particular underscores
	frame=single,                   % adds a frame around the code
	rulecolor=\color{UCLABlue},     % if not set, the frame-color may be changed on 
	rulesepcolor=\color{UCLABlue},  %line-breaks within not-black text (e.g. comments (green here))
	tabsize=2,                      % sets default tabsize to 2 spaces
	captionpos=b,                   % sets the caption-position to bottom
	breaklines=true,                % sets automatic line breaking
	breakatwhitespace=false,        % sets if automatic breaks should only happen at whitespace
	title=\lstname,                 % show the filename of files included with \lstinputlisting;
	                                % also try caption instead of title
	commentstyle=\color{DarkGreen}, % comment style
	stringstyle=\color{VioletRed},  % string literal style
	classoffset=0,
	classoffset=1,
	classoffset=0,
	breaklines=true,
  %
  extendedchars=true,
  literate=
  {á}{{\'a}}1 {é}{{\'e}}1 {í}{{\'i}}1 {ó}{{\'o}}1 {ú}{{\'u}}1
  {Á}{{\'A}}1 {É}{{\'E}}1 {Í}{{\'I}}1 {Ó}{{\'O}}1 {Ú}{{\'U}}1
  {à}{{\`a}}1 {è}{{\`e}}1 {ì}{{\`i}}1 {ò}{{\`o}}1 {ù}{{\`u}}1
  {À}{{\`A}}1 {È}{{\'E}}1 {Ì}{{\`I}}1 {Ò}{{\`O}}1 {Ù}{{\`U}}1
  {ä}{{\"a}}1 {ë}{{\"e}}1 {ï}{{\"i}}1 {ö}{{\"o}}1 {ü}{{\"u}}1
  {Ä}{{\"A}}1 {Ë}{{\"E}}1 {Ï}{{\"I}}1 {Ö}{{\"O}}1 {Ü}{{\"U}}1
  {â}{{\^a}}1 {ê}{{\^e}}1 {î}{{\^i}}1 {ô}{{\^o}}1 {û}{{\^u}}1
  {Â}{{\^A}}1 {Ê}{{\^E}}1 {Î}{{\^I}}1 {Ô}{{\^O}}1 {Û}{{\^U}}1
  {œ}{{\oe}}1 {Œ}{{\OE}}1 {æ}{{\ae}}1 {Æ}{{\AE}}1 {ß}{{\ss}}1
  {ç}{{\c c}}1 {Ç}{{\c C}}1 {ø}{{\o}}1 {å}{{\r a}}1 {Å}{{\r A}}1
  {€}{{\EUR}}1 {£}{{\pounds}}1
}

%%
%% Python definition (c) 1998 Michael Weber
%% Additional definitions (2013) Alexis Dimitriadis
%% modified by me (should not have empty lines)
%%
\lstdefinelanguage{iPython}{
    morekeywords={access,and,break,class,continue,def,del,elif,else,except,exec,finally,for,from,global,if,import,as,in,is,lambda,not,or,pass,print,raise,return,try,while},%
    %
    % Built-ins
    morekeywords=[2]{abs,all,any,basestring,bin,bool,bytearray,callable,chr,classmethod,cmp,compile,complex,delattr,dict,dir,divmod,enumerate,eval,execfile,file,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,list,locals,long,map,max,memoryview,min,next,object,oct,open,ord,pow,property,range,raw_input,reduce,reload,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,unichr,unicode,vars,xrange,zip,apply,buffer,coerce,intern},%
    %
    sensitive=true,%
    morecomment=[l]\#,%
    morestring=[b]',%
    morestring=[b]",%
    %
    morestring=[s]{'''}{'''},% used for documentation text (mulitiline strings)
    morestring=[s]{"""}{"""},% added by Philipp Matthias Hahn
    %
    morestring=[s]{r'}{'},% `raw' strings
    morestring=[s]{r"}{"},%
    morestring=[s]{r'''}{'''},%
    morestring=[s]{r"""}{"""},%
    morestring=[s]{u'}{'},% unicode strings
    morestring=[s]{u"}{"},%
    morestring=[s]{u'''}{'''},%
    morestring=[s]{u"""}{"""},%
    %
    % {replace}{replacement}{lenght of replace}
    % *{-}{-}{1} will not replace in comments and so on
    literate=
    {á}{{\'a}}1 {é}{{\'e}}1 {í}{{\'i}}1 {ó}{{\'o}}1 {ú}{{\'u}}1
    {Á}{{\'A}}1 {É}{{\'E}}1 {Í}{{\'I}}1 {Ó}{{\'O}}1 {Ú}{{\'U}}1
    {à}{{\`a}}1 {è}{{\`e}}1 {ì}{{\`i}}1 {ò}{{\`o}}1 {ù}{{\`u}}1
    {À}{{\`A}}1 {È}{{\'E}}1 {Ì}{{\`I}}1 {Ò}{{\`O}}1 {Ù}{{\`U}}1
    {ä}{{\"a}}1 {ë}{{\"e}}1 {ï}{{\"i}}1 {ö}{{\"o}}1 {ü}{{\"u}}1
    {Ä}{{\"A}}1 {Ë}{{\"E}}1 {Ï}{{\"I}}1 {Ö}{{\"O}}1 {Ü}{{\"U}}1
    {â}{{\^a}}1 {ê}{{\^e}}1 {î}{{\^i}}1 {ô}{{\^o}}1 {û}{{\^u}}1
    {Â}{{\^A}}1 {Ê}{{\^E}}1 {Î}{{\^I}}1 {Ô}{{\^O}}1 {Û}{{\^U}}1
    {œ}{{\oe}}1 {Œ}{{\OE}}1 {æ}{{\ae}}1 {Æ}{{\AE}}1 {ß}{{\ss}}1
    {ç}{{\c c}}1 {Ç}{{\c C}}1 {ø}{{\o}}1 {å}{{\r a}}1 {Å}{{\r A}}1
    {€}{{\EUR}}1 {£}{{\pounds}}1
    %
    {^}{{{\color{ipython_purple}\^{}}}}1
    {=}{{{\color{ipython_purple}=}}}1
    %
    {+}{{{\color{ipython_purple}+}}}1
    {*}{{{\color{ipython_purple}$^\ast$}}}1
    {/}{{{\color{ipython_purple}/}}}1
    %
    {+=}{{{+=}}}1
    {-=}{{{-=}}}1
    {*=}{{{$^\ast$=}}}1
    {/=}{{{/=}}}1,
    literate=
    *{-}{{{\color{ipython_purple}-}}}1
     {?}{{{\color{ipython_purple}?}}}1,
    %
    identifierstyle=\color{black}\ttfamily,
    commentstyle=\color{ipython_cyan}\ttfamily,
    stringstyle=\color{ipython_red}\ttfamily,
    keepspaces=true,
    showspaces=false,
    showstringspaces=false,
    %
    rulecolor=\color{ipython_frame},
    frame=single,
    frameround={t}{t}{t}{t},
    framexleftmargin=6mm,
    numbers=left,
    numberstyle=\tiny\color{halfgray},
    %
    %
    backgroundcolor=\color{ipython_bg},
    %   extendedchars=true,
    basicstyle=\scriptsize,
    keywordstyle=\color{ipython_green}\ttfamily,
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% End Preamble %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}

\thispagestyle{empty}

\begin{center}
  \fbox{\parbox{\linewidth}{\centering \large \courselabel{} \extitle{}: \exyear{}}}
\end{center}

\begin{questions}
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Start %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  % INSERT CONTENT HERE %

  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% End %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\end{questions}

\end{document}
