\documentclass[12pt,twoside,addpoints]{exam}

\usepackage{enumitem}
\usepackage{amsmath}
\usepackage[top=15mm,bottom=20mm,right=15mm,left=15mm]{geometry}
\usepackage{hyperref}
\usepackage{tkz-graph}
\usepackage{multicol}
\usepackage{tikz}
\usepackage{caption}
\usepackage{pgfplots}
\usepackage{verbatim}
\usepackage{amssymb}
\usetikzlibrary{calc}
\usetikzlibrary{arrows.meta}

\DeclareMathOperator{\Dirichlet}{D}


\boxedpoints
\pointsinrightmargin
\setlength{\rightpointsmargin}{1.5cm}

\title{\vspace*{-2cm}22 Problems}
\author{Aayush Bajaj}
\date{\today\vspace*{-0.5cm}}

\cfoot{\thepage}

\noprintanswers
\renewenvironment{solutionordottedlines}[1][]
  {% begin code
   \def\@tempa{#1}%
   \expandafter\comment
  }
  {% end code
   \expandafter\endcomment
  }
\makeatother
\renewenvironment{solutionorbox}[1][]
  {% begin code
   \def\@tempa{#1}%
   \expandafter\comment
  }
  {% end code
   \expandafter\endcomment
  }
\makeatother

\begin{document}

\maketitle

\noindent\fbox{
    \parbox{\textwidth}{Welcome! Today is the $26^{th}$ of December, and it is my birthday :D.\\\\Today we are going to be playing a game called \textit{22 Problems}. This game consists of 22 (mostly) \textbf{mathematical} problems and whoever has the highest score by the deadline will be the winner!
}
}

\bigbreak
\dotfill

\section*{Rules}
\begin{enumerate}
    \item You must try to avoid using the internet. All books are fair game.
    \item If your work is unpleasant to read, and / or difficult to mark, I shall discard it.
    \item The boxed numbers in the right margin are marks.
    \item Deadline: \textit{11:59PM}, 31st of December 2023.
    \item Submission: \LaTeX{} appraised, hand-written accepted. \textsc{filename must be your full name!}
\end{enumerate}

\begin{center}
\begin{tikzpicture}
  % Button background
  \node[draw, rounded corners=8pt, fill=blue!30, inner sep=10pt] (button) {\textbf{Submit}};

  % Text label

  % Define the URL
  \def\myurl{https://abaj.io/bday/problems/upload}

  % Add a link
    \node[anchor=center] (link) at (button.center) {\href{\myurl}{\phantom{Submit}}};

\end{tikzpicture}
\end{center}


\hrulefill

\section*{Problems}
\begin{questions}
    \question[2] \[\int_0^3 \sqrt{9-x^2}\, \mathrm{d}x\]
        \begin{solutionordottedlines}[2cm]
        \end{solutionordottedlines}
    \question[2] \[2\iiint\limits_{V} \,\mathrm{d}V, V : \{(r, \theta, \phi) \,|\, 0 \leq r \leq 1,\, 0 \leq \theta \leq 2\pi,\, 0\leq \phi \leq \pi\}\]
        \begin{solutionordottedlines}[1in]
        \end{solutionordottedlines}
    \question[3] \[\int \frac{\cos{x}}{3+2\cos{x}} \, \mathrm{d}x\]
        \begin{solutionordottedlines}[1in]
        \end{solutionordottedlines}
    \question[2] Precisely mark out $\sqrt{2}$ on a number line.
        \begin{solutionorbox}[1in]
        \end{solutionorbox}
    \question[2] What is the exact value of $(\frac{3}{2})!$
        \begin{solutionordottedlines}[1in]
        \end{solutionordottedlines}
    \question[3] Prove the Pythagorean Theorem.
        \begin{solutionordottedlines}[1.5in]
        \end{solutionordottedlines}
    \question[4] Find the derivative of $\sin{x}$ using first principles. State any and all lemmas.
        \begin{solutionordottedlines}[2in]
        \end{solutionordottedlines}
    \question 
    \begin{parts}
        \part[1] List the first 10 terms of the Fibonacci sequence.
            \begin{solutionordottedlines}[0.5in]
            \end{solutionordottedlines}
        \part[2] Explain how this sequence is present in the \textbf{Mandelbrot Set}.
            \begin{solutionordottedlines}[1in]
            \end{solutionordottedlines}
    \end{parts}
    \question[3] \[\int^\infty_\infty \mathrm{e}^{-x^2} \,\mathrm{d}x\]
        \begin{solutionordottedlines}[1.5in]
        \end{solutionordottedlines}
    \question[2] What does the sum $1 - \frac{1}{3} + \frac{1}{5} - \frac{1}{7} + \frac{1}{9} - ...$ converge to?
        \begin{solutionordottedlines}[1in]
            $\frac{\pi}{4}$
        \end{solutionordottedlines}
    \question[1] Calculus is for \fillin[children] whilst analysis is for \fillin[adults].
    \question[2] What is the angle between the two curves $f(x) = x^4 -5x^3$ and $g(x) = 8x-40$ at either of their points of intersection?
        \begin{solutionordottedlines}[1in]
        \end{solutionordottedlines}
    \question[2] What is the shortest path you can take from node $s$ to node $t$ in figure 1?
        \begin{solutionordottedlines}[1in]
        \end{solutionordottedlines}
    \question[2] What are the \textbf{complex} solutions to $\sin(z) = 2$?
        \begin{solutionordottedlines}[1in]
        \end{solutionordottedlines}
    \question
    \begin{parts}
        \part[4] Find a closed form for the recurrence $T(n) = T(n-1) + T(n-2)$, with initial conditions $T(0) = 0$ and $T(1) = 1$.
        \begin{solutionordottedlines}[1in]
            \[T(n) = \frac{\varphi^n-(1-\varphi)^n}{\sqrt{5}}\]
        \end{solutionordottedlines}
        \part[1] Hence find $T(27)$.
    \end{parts}
        \begin{solutionordottedlines}[1in]
            $196,418$
        \end{solutionordottedlines}
    \question[2] Solve the following differential equation $y'' + 2y' + y = e^{-x}\cos(x)$ with initial value conditions of $y = 0$ and $y' = 1$.
        \begin{solutionordottedlines}[1in]
            $y(x) = (x-\cos(x)+1)e^{-x}$
        \end{solutionordottedlines}
    \question[2] What is the dot product of the functions $\sin(x)$ and $\cos(x)$Linear question.
        \begin{solutionordottedlines}[1in]
            $0$
        \end{solutionordottedlines}
    \question[3] How many permutations of the Rubiks cube exist? Give your answer as an expression.
        \begin{solutionordottedlines}[1in]
            $8! \times 3^7 \times 12! \times 2^{11} = 43,252,003,274,489,856,000$
        \end{solutionordottedlines}
    \question[2] Decode using the Caesar cipher: \textit{Urqh zdv qrw exlow lq d gdb}.
        \begin{solutionordottedlines}[1in]
            Rome was not built in a day.
        \end{solutionordottedlines}
    \question[2] Calculate the length of the curve from $0$ to $4$ for $f(x) = x^2$.
        \begin{solutionordottedlines}[1in]
        \end{solutionordottedlines}
    \question[2] Negate the following statement and reexpress it as an equivalent positive one.
    \textsc{Everyone who is majoring in math has a friend who needs help with his or her homework.}
        \begin{solutionordottedlines}[1in]
            There is at least one math major who has no friends needing help with their homework.
        \end{solutionordottedlines}
    \question[2] Let the Dirichlet function be defined as:
        \[
        \Dirichlet(x) =
        \begin{cases} 
        1 & \text{if } x \text{ is rational}, \\
        0 & \text{if } x \text{ is irrational}.
        \end{cases}
        \]
        Thus evaluate \(\int_0^1 D(x), \mathrm{d}x\).

        \begin{solutionordottedlines}[1in]
            $0$
        \end{solutionordottedlines}
\end{questions}


\newpage
\section*{Diagrams}
\begin{multicols}{3}
    \begin{minipage}{\linewidth}
        \begin{tikzpicture}[scale=0.65,transform shape]
          % Nodes
          \Vertex[x=0,y=0, L={$s$}]{s}
          \Vertex[x=2,y=2, L={$v_1$}]{v1}
          \Vertex[x=2,y=-2, L={$v_2$}]{v2}
          \Vertex[x=5,y=2, L={$v_3$}]{v3}
          \Vertex[x=5,y=-2, L={$v_4$}]{v4}
          \Vertex[x=7,y=0, L={$t$}]{t}

          % Edges
          \tikzset{EdgeStyle/.append style = {->, >=Latex, line width=1pt}}
          \Edge[label=16](s)(v1)
          \Edge[label=13](s)(v2)
          \Edge[label=12](v1)(v3)
          \Edge[label=9](v2)(v3)
          \Edge[label=14](v2)(v4)
          \Edge[label=7](v3)(v4)
          \Edge[label=20](v3)(t)
          \Edge[label=4](v4)(t)
          \tikzset{EdgeStyle/.append style = {bend left = 15}}
          \Edge[label=4](v1)(v2)
          \Edge[label=10](v2)(v1)
        \end{tikzpicture}
        \captionof*{figure}{}
    \end{minipage}
    \begin{minipage}{\linewidth}
        \begin{tikzpicture}[scale=0.6, transform shape]
        \begin{axis}[
            axis lines = left,
            xlabel = \( x \),
            ylabel = {\( y \)},
            ylabel style={rotate=-90},
        ]

        % Plot the function y = x^2
        \addplot [
            domain=-1:5, 
            samples=100, 
            color=red,
        ] {x^2};

        % Highlight the section from 0 to 4 in blue
        \addplot [
            domain=0:4,
            samples=100,
            color=blue,
            thick,
        ] {x^2};

        \end{axis}
        \end{tikzpicture}
    \end{minipage}
    \begin{minipage}{\linewidth}
        \begin{tikzpicture}[scale=0.7]
            \begin{axis}[
                axis lines=middle,
                xmin=0, xmax=1,
                ymin=0, ymax=1.5,
                xlabel=$x$,
                ylabel=$f(x)$,
                ytick={0, 1},
                yticklabels={0, 1},
                small
            ]
            
            % Define a fixed non-zero denominator for rational numbers
            \def\denominator{10}
            
            % Plot rational points
            \foreach \p in {1,...,100}{
                \pgfmathsetmacro{\rational}{mod(\p/\denominator, 1)}
                \addplot[only marks, mark=*, mark options={scale=0.3}, color=blue] coordinates {(\rational, 1)};
            }
            
            % Plot irrational points
            \foreach \i in {1,...,100}{
                \pgfmathsetmacro{\irrational}{mod(\i*sqrt(2), 1)}
                \addplot[only marks, mark=*, mark options={scale=0.3}, color=red] coordinates {(\irrational, 0)};
            }

            \end{axis}
        \end{tikzpicture}
    \end{minipage}
\end{multicols}


\section*{Marking}

\multirowgradetable{2}[questions]

\end{document}
