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} |