slides/slides04.tex
changeset 325 ca9c1cf929fa
parent 229 5549016ab10f
child 326 e5453add7df6
equal deleted inserted replaced
324:2969ee4a6cee 325:ca9c1cf929fa
       
     1 % !TEX program = xelatex
     1 \documentclass[dvipsnames,14pt,t,xelatex]{beamer}
     2 \documentclass[dvipsnames,14pt,t,xelatex]{beamer}
     2 \usepackage{../slides}
     3 \usepackage{../slides}
     3 \usepackage{../graphics}
     4 \usepackage{../graphics}
     4 \usepackage{../langs}
     5 \usepackage{../langs}
     5 %%\usepackage{../data}
     6 %%\usepackage{../data}
   143 
   144 
   144   \normalsize
   145   \normalsize
   145   \begin{center}
   146   \begin{center}
   146   \begin{tabular}{ll}
   147   \begin{tabular}{ll}
   147     Email:  & christian.urban at kcl.ac.uk\\
   148     Email:  & christian.urban at kcl.ac.uk\\
   148     Office: & N\liningnums{7.07} (North Wing, Bush House)\\
   149     Office: & N\liningnums{7.07} (North Wing, Bush House)\bigskip\\
   149     Slides \& Code: & KEATS\medskip\\
   150     Slides \& Code: & KEATS\\
   150     Office Hours: &  Mondays 12:00 -- 14:00\\
   151                     & \onslide<2>{\alert{A Crash-Course in Scala}}\bigskip\\
       
   152     Office Hours: &  Thursdays 12:00 -- 14:00\\
       
   153     Additionally: & (for Scala) Tuesdays 10:45 -- 11:45\\ 
   151   \end{tabular}
   154   \end{tabular}
   152   \end{center}
   155   \end{center}
   153 
   156 
   154 
   157 
   155 \end{frame}
   158 \end{frame}
   156 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
   159 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
   157 
   160 
   158 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
   161 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   159 
       
   160 \begin{frame}[c]
   162 \begin{frame}[c]
   161 \frametitle{Somewhere Remote}
   163 \frametitle{Hints in CW}
   162 
   164 
   163 \begin{center}
   165 \begin{center}  
   164 \includegraphics[scale=0.37]{../pics/sahara.jpg}
   166 \includegraphics[scale=0.4]{../pics/hints.png}
   165 \end{center}
   167 \end{center}
   166 
   168 
   167 \end{frame}
       
   168 
       
   169 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   170 
       
   171 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
       
   172 
       
   173 \begin{frame}[t]
       
   174 \frametitle{This is a bit harsh\ldots}
       
   175 
       
   176 \mbox{}\\[-22mm]\mbox{}
       
   177 
       
   178 \begin{center}
       
   179 \begin{bubble}[10.5cm]
       
   180   ...trying a new method because the fucking github reports dont tell me
       
   181   which test failed. It's not really helpful when the inline tests work
       
   182   and it compiles but all i get is 'one test failed'... really helpful my dude.
       
   183 \end{bubble}
       
   184 \end{center}
       
   185 
       
   186 \begin{center}
       
   187 \begin{bubble}[10.5cm]
       
   188   ...Reverted back and finished part 5, this is ridiculous how one test works
       
   189   and all I get is 'ONE TEST FAILED'. Fix your reports before giving us
       
   190   assignments like this...
       
   191 \end{bubble}
       
   192 \end{center}
       
   193 
       
   194 
       
   195 \end{frame}
       
   196 
       
   197 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
       
   198 
       
   199 \begin{frame}[t,fragile]
       
   200 \frametitle{Needless to say I tried it out}
       
   201 
       
   202 \mbox{}\\[-7mm]\mbox{}\footnotesize
       
   203 
       
   204 \begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-4mm]
       
   205 > legal_moves(8, Nil, (2,2))
       
   206  = List((3,4), (4,3), (4,1), (3,0), (1,0), (0,1), (0,3), (1,4))
       
   207 
       
   208 > legal_moves(8, Nil, (7,7))
       
   209  = List((6,5), (5,6))
       
   210 
       
   211 > legal_moves(8, List((4,1), (1,0)), (2,2))
       
   212  = List((3,4), (4,3), (3,0), (0,1), (0,3), (1,4))
       
   213 
       
   214 > legal_moves(1, Nil, (0,0))
       
   215  = List((-1,-2), (-2,-1))
       
   216 
       
   217 > legal_moves(2, Nil, (0,0))
       
   218  = List((1,-2), (-1,-2), (-2,-1), (-2,1))
       
   219 
       
   220 > legal_moves(3, Nil, (0,0))
       
   221  = List((1,2), (2,1), (2,-1), (1,-2), (-1,-2), (-2,-1), (-2,1), (-1,2))
       
   222 \end{lstlisting}  
       
   223 
       
   224 \LEFTarrow{1}{9}{9}
       
   225 \LEFTarrow{1}{12}{11}
       
   226 \DOWNarrow{1}{10}{13}
       
   227 
       
   228 \end{frame}
       
   229 
       
   230 
       
   231 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   232 
       
   233 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   234 \begin{frame}[c,fragile]
       
   235 \small
   169 \small
   236   
   170 \begin{itemize}
   237 \begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-7mm]
   171   \item Scala Library, e.g.~\texttt{span} in \\
   238 def is_legal(dim: Int, p: Path, x: Pos): Boolean = {
   172   \url{https://www.scala-lang.org/api/current/scala/collection/immutable/List.html}
   239   if (......some_really_long_condition.....) false
   173 \end{itemize}
       
   174 \end{frame}
       
   175 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   176   
       
   177 
       
   178 
       
   179 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
       
   180 \begin{frame}[c]
       
   181 \frametitle{Preliminary 7}
       
   182 
       
   183 Raw marks (261 submissions):\bigskip
       
   184 
       
   185 \begin{itemize}
       
   186 \item 4\%: \hspace{4mm}236
       
   187 \item 3\%: \hspace{4mm}10
       
   188 \item 2\%: \hspace{4mm}1
       
   189 \item 1\%: \hspace{4mm}0
       
   190 \item 0\%: \hspace{4mm}15 
       
   191 \end{itemize}\bigskip\bigskip  
       
   192 
       
   193 \footnotesize
       
   194 (interviews ongoing!)
       
   195 
       
   196 \end{frame}
       
   197 
       
   198 
       
   199 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   200 
       
   201 
       
   202 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   203 \begin{frame}[c,fragile]
       
   204 \small
       
   205   
       
   206 \begin{lstlisting}[language=Scala, numbers=none, xleftmargin=1mm]
       
   207 def is_legal(dim: Int, p: Path, x: Pos) = {
       
   208   if (...some_really_long_condition...) false
   240   else true
   209   else true
   241 }
   210 }
   242 \end{lstlisting}
   211 \end{lstlisting}
   243 
   212 
   244 \pause
   213 \pause
   245 \bigskip
   214 \bigskip
   246 \rule{11cm}{0.3mm}
   215 \rule{11cm}{0.3mm}
   247 \bigskip
   216 \bigskip
   248 
   217 
       
   218 \begin{lstlisting}[language=Scala, numbers=none, xleftmargin=1mm]
       
   219 def is_legal(dim: Int, p: Path, x: Pos) = 
       
   220   !(...some_really_long_condition...)
       
   221 \end{lstlisting}
       
   222 
       
   223 \end{frame}
       
   224 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
       
   225 
       
   226 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   227 \begin{frame}[c,fragile]
       
   228 \small
       
   229   
       
   230 \begin{lstlisting}[language=Scala, numbers=none, xleftmargin=1mm]
       
   231 def foobar(...) = {
       
   232   val cs = for (c <- str) yield c.toLowerCase
       
   233   ...
       
   234 }
       
   235 \end{lstlisting}
       
   236 
       
   237 \pause
       
   238 \bigskip
       
   239 \rule{11cm}{0.3mm}
       
   240 \bigskip
       
   241 
       
   242 \begin{lstlisting}[language=Scala, numbers=none, xleftmargin=1mm]
       
   243 def foobar(...) = {
       
   244   val cs = str.map(_.toLowerCase)
       
   245   ...
       
   246 }
       
   247 \end{lstlisting}
       
   248 
       
   249 \end{frame}
       
   250 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
       
   251 
       
   252 
       
   253 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   254 \begin{frame}[c,fragile]
       
   255 \small
       
   256   
   249 \begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-7mm]
   257 \begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-7mm]
   250 def is_legal(dim: Int, p: Path, x: Pos): Boolean = 
   258 def RomanNumeral2Int(rs: RomanNumeral): Int = 
   251   !......some_really_long_condition.....
   259  rs match { 
   252 \end{lstlisting}\pause
   260    case Nil => 0
   253 
   261    case M::r    => 1000 + RomanNumeral2Int(r)  
       
   262    case C::M::r => 900 + RomanNumeral2Int(r)
       
   263    case D::r    => 500 + RomanNumeral2Int(r)
       
   264    case C::D::r => 400 + RomanNumeral2Int(r)
       
   265    case C::r    => 100 + RomanNumeral2Int(r)
       
   266    case X::C::r => 90 + RomanNumeral2Int(r)
       
   267    case L::r    => 50 + RomanNumeral2Int(r)
       
   268    case X::L::r => 40 + RomanNumeral2Int(r)
       
   269    case X::r    => 10 + RomanNumeral2Int(r)
       
   270    case I::X::r => 9 + RomanNumeral2Int(r)
       
   271    case V::r    => 5 + RomanNumeral2Int(r)
       
   272    case I::V::r => 4 + RomanNumeral2Int(r)
       
   273    case I::r    => 1 + RomanNumeral2Int(r)
       
   274  }
       
   275 \end{lstlisting}
   254 
   276 
   255 \end{frame}
   277 \end{frame}
   256 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
   278 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
   257 
   279 
       
   280 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   281 \begin{frame}[c,fragile]
       
   282 \frametitle{Last Week: Pattern Matching} 
       
   283 \small
       
   284   
       
   285 \begin{lstlisting}[language=Scala, numbers=none, xleftmargin=3mm]
       
   286 def fizz_buzz(n: Int) : String = 
       
   287   (n % 3, n % 5) match {
       
   288     case (0, 0) => "fizz buzz"
       
   289     case (0, _) => "fizz"
       
   290     case (_, 0) => "buzz"
       
   291     case _ => n.toString  
       
   292   }
       
   293 \end{lstlisting}
       
   294 
       
   295 \end{frame}
       
   296 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
       
   297 
       
   298 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
       
   299 \begin{frame}[c,fragile]
       
   300 \frametitle{Reverse Polish Notation}
       
   301 
       
   302 {\Large\bl{$(3 + 1) * (2 + 9)$}}\bigskip
       
   303 
       
   304 {\Large$\Rightarrow$}\bigskip
       
   305 
       
   306 {\;\;\Large\bl{$3\;\;1\;+\;2\;\;9\;+\;*$}}
       
   307 
       
   308 \begin{textblock}{3}(11,4)
       
   309 \begin{onlyenv}<2>
       
   310 \begin{lstlisting}[language=JVMIS]
       
   311 ldc 3
       
   312 ldc 1
       
   313 iadd
       
   314 ldc 2
       
   315 ldc 9
       
   316 iadd
       
   317 imul
       
   318 \end{lstlisting}
       
   319 \end{onlyenv} 
       
   320 \end{textblock}
       
   321 
       
   322 \end{frame}
       
   323 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   324  
       
   325 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
       
   326 \begin{frame}[c,fragile]
       
   327 \frametitle{Sudoku}
       
   328 
       
   329 A very simple-minded version on 110 problems:\bigskip
       
   330 
       
   331 \begin{itemize}
       
   332 \item 1 core: 800 secs
       
   333 \item 2 cores: 400 secs
       
   334 \item 8 cores: 290 secs
       
   335 \item 18 cores: 142 secs
       
   336 \end{itemize}
       
   337 
       
   338 \end{frame}
       
   339 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   340  
   258 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   341 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   259 \begin{frame}[c]
   342 \begin{frame}[c]
   260 \frametitle{DFAs}  
   343 \frametitle{DFAs}  
   261 
   344 
   262 \begin{center}
   345 \begin{center}
   347 
   430 
   348 \end{frame}
   431 \end{frame}
   349 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   432 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   350 
   433 
   351 
   434 
   352 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   435 
   353 \begin{frame}[c]
   436 \begin{frame}[t]
   354   \frametitle{CW\liningnums{9} (\liningnums{1} Part): Regexes}
   437 
   355   
   438   \begin{center}  
   356 \begin{center}
   439   \includegraphics[scale=0.3]{../pics/blow.png}
   357   Graphs: $(a^*)^* b$ and strings $\underbrace{\;a\ldots a\;}_{n}$\bigskip
   440   \end{center}
       
   441   
       
   442   \begin{textblock}{14}(2,11.4)
       
   443   \large\bf{}Mind-Blowing Regular Expressions:\\ 
       
   444   \centering in Python, JavaScript, Java
       
   445   \end{textblock}
       
   446 \end{frame}
       
   447 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   448 
       
   449 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   450 \begin{frame}[c,fragile]
       
   451 \frametitle{Regular Expressions} 
       
   452   
       
   453 Suppose you have a regular expression 
       
   454 \only<1-3>{\alert{\texttt{(a*)b}}}%
       
   455 \only<4->{\alert{\texttt{(a*)*b}}} :\bigskip
       
   456 
       
   457 \begin{center}
       
   458 \only<1>{\code{"aaaaaaaaaaaaaaab"}}
       
   459 \only<2>{\code{"aaaaa...........aaaaaaaaaaaaaaaaaaaab"}}
       
   460 \only<3>{\code{"aaaaa...........aaaaaaaaaaaaaaaaaaaa"}}
       
   461 \only<4>{\code{"aaaaa...........aaaaaaaaaaaaaaaaaaaab"}}
       
   462 \only<5->{\code{"aaaaa...........aaaaaaaaaaaaaaaaaaaa"}}
       
   463 \end{center}
       
   464 
       
   465 \only<6>{
       
   466 \begin{textblock}{13}(5,12)
       
   467 How long does Python need to find out?
       
   468 \end{textblock}}
       
   469 
       
   470 \end{frame}
       
   471 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
       
   472 
       
   473 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   474 \begin{frame}<1>[c]
       
   475   \frametitle{CW 9: Regexes}
       
   476   
       
   477 \begin{center}
       
   478   Graphs: \alert{\texttt{(a*)*b}} and strings $\underbrace{\;\texttt{a}\ldots \texttt{a}\;}_{n}$\bigskip
   358   
   479   
   359 \begin{tabular}[t]{@{\hspace{-8mm}}c@{\hspace{-4mm}}c@{}}
   480 \begin{tabular}[t]{@{\hspace{-8mm}}c@{\hspace{-4mm}}c@{}}
   360 \only<1>{\raisebox{6mm}{\begin{tikzpicture}
   481 \only<1>{\raisebox{6mm}{\begin{tikzpicture}
   361 \begin{axis}[
   482 \begin{axis}[
   362     xlabel={$n$},
   483     xlabel={$n$},
   419 \end{tabular}
   540 \end{tabular}
   420 \end{center}
   541 \end{center}
   421 
   542 
   422 \hfill\small\url{https://vimeo.com/112065252}
   543 \hfill\small\url{https://vimeo.com/112065252}
   423 \end{frame}
   544 \end{frame}
   424 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
   545 
   425 
   546 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   547 
       
   548 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
   426 \begin{frame}[c]
   549 \begin{frame}[c]
   427 \frametitle{Hint}
   550 
   428 
   551 \begin{center}
   429 \begin{center}
   552   \includegraphics[angle=90,scale=0.35]{/Users/cu/vote.pdf}
   430 \LARGE\textbf{\alert{Pattern-Matching}}
   553 \end{center}
   431 \end{center}
   554 
   432 
   555 \end{frame}
   433 \end{frame}
   556 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
   434 
   557 
   435 
   558 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
   436 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   559 \begin{frame}[c]
   437 
   560 
   438 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   561 \begin{center}
   439 \begin{frame}[c,fragile]
   562   \includegraphics[scale=0.25]{/Users/cu/dresden.png}
   440 \frametitle{\alert{Questions?}}
   563 \end{center}
   441 
   564 
   442 \end{frame}
   565 \begin{textblock}{13}(2,12)
   443 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   566 \includegraphics[scale=0.08]{/Users/cu/kiss.jpg}
       
   567 \end{textblock}
       
   568 
       
   569 \begin{textblock}{13}(6.8,12)
       
   570 \includegraphics[scale=0.079]{/Users/cu/pioniere.jpg}
       
   571 \end{textblock}
       
   572 
       
   573 \begin{textblock}{13}(11,12)
       
   574 \includegraphics[scale=0.20]{/Users/cu/iron.jpg}
       
   575 \end{textblock}
       
   576 
       
   577 \DOWNarrow{1}{11}{8.6}
       
   578 
       
   579 \end{frame}
       
   580 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
       
   581 
   444 
   582 
   445 
   583 
   446 
   584 
   447 \end{document}
   585 \end{document}
   448 
   586