day1/Session-2.tex
changeset 87 cd29428cd8f5
parent 86 f657495cf8b2
child 109 16e04782baac
equal deleted inserted replaced
86:f657495cf8b2 87:cd29428cd8f5
    85 %\logo{\pgfuseimage{iitmlogo}}
    85 %\logo{\pgfuseimage{iitmlogo}}
    86 
    86 
    87 
    87 
    88 %% Delete this, if you do not want the table of contents to pop up at
    88 %% Delete this, if you do not want the table of contents to pop up at
    89 %% the beginning of each subsection:
    89 %% the beginning of each subsection:
    90 \AtBeginSubsection[]
    90 \AtBeginSection[]
    91 {
    91 {
    92   \begin{frame}<beamer>
    92   \begin{frame}<beamer>
    93     \frametitle{Outline}
    93     \frametitle{Outline}
    94     \tableofcontents[currentsection,currentsubsection]
    94     \tableofcontents[currentsection,subsections]
    95   \end{frame}
    95   \end{frame}
    96 }
    96 }
    97 
    97 
    98 
    98 
    99 % If you wish to uncover everything in a step-wise fashion, uncomment
    99 % If you wish to uncover everything in a step-wise fashion, uncomment
   121   \end{itemize}
   121   \end{itemize}
   122 \end{frame}
   122 \end{frame}
   123 
   123 
   124 \begin{frame}{Problem 1.1}
   124 \begin{frame}{Problem 1.1}
   125   Write a program that displays all three digit numbers that are equal to the sum of the cubes of their digits. That is, print numbers $abc$ that have the property $abc = a^3 + b^3 + c^3$\\
   125   Write a program that displays all three digit numbers that are equal to the sum of the cubes of their digits. That is, print numbers $abc$ that have the property $abc = a^3 + b^3 + c^3$\\
   126 \begin{block}
   126 \vspace*{0.2in}
   127 {Information...}
   127 \emphbar{These are called $Armstrong$ numbers.}
   128 These are called $Armstrong$ numbers.
       
   129 \end{block}
       
   130 \end{frame}
   128 \end{frame}
   131   
   129   
   132 \begin{frame}{Problem 1.2 - Collatz sequence}
   130 \begin{frame}{Problem 1.2 - Collatz sequence}
   133 \begin{enumerate}
   131 \begin{enumerate}
   134   \item Start with an arbitrary (positive) integer. 
   132   \item Start with an arbitrary (positive) integer. 
   148 3  3  3
   146 3  3  3
   149 4  4  4  4
   147 4  4  4  4
   150   \end{lstlisting}
   148   \end{lstlisting}
   151 The number of lines must be obtained from the user as input.\\
   149 The number of lines must be obtained from the user as input.\\
   152 \pause
   150 \pause
   153 When can your code fail?
   151 \emphbar{When can your code fail?}
   154 \only<2->{\inctime{20}}
   152 \only<2->{\inctime{20}}
   155 \end{frame}
   153 \end{frame}
   156 
   154 
   157 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   155 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   158 % TIME: 20 m, running 20m 
   156 % TIME: 20 m, running 20m 
   187     s = str( n )
   185     s = str( n )
   188     padSize = size - len( s )
   186     padSize = size - len( s )
   189     return padSize * SPACE + s
   187     return padSize * SPACE + s
   190   \end{lstlisting}
   188   \end{lstlisting}
   191 \pause
   189 \pause
   192 What about \%3d?
   190 \emphbar{What about \% formatting?}
   193 \end{frame}
   191 \end{frame}
   194 
   192 
   195 \begin{frame}[fragile]
   193 \begin{frame}[fragile]
   196   {What does this function do?}
   194   {What does this function do?}
   197   \begin{lstlisting}
   195   \begin{lstlisting}
   324 >>> a[::2]
   322 >>> a[::2]
   325 [1, 3]
   323 [1, 3]
   326 >>> a[-1::-1]
   324 >>> a[-1::-1]
   327 \end{lstlisting}
   325 \end{lstlisting}
   328 What do you think the last one will do?
   326 What do you think the last one will do?
   329   \emphbar{Note: Strings also use same indexing and slicing.}
   327   \emphbar{Strings also use same indexing and slicing.}
   330 \end{frame}
   328 \end{frame}
   331 
   329 
   332 \begin{frame}[fragile]
   330 \begin{frame}[fragile]
   333   \frametitle{List: examples}
   331   \frametitle{List: examples}
   334 \begin{lstlisting}
   332 \begin{lstlisting}