# HG changeset patch # User Christian Urban # Date 1572359691 0 # Node ID ec9773fe1dc09d3b4c724b8a18ac78523326391e # Parent 87b9e3e2c1a7f08795b8de5486c2e1ba4abb421f updated diff -r 87b9e3e2c1a7 -r ec9773fe1dc0 cws/cw01.pdf Binary file cws/cw01.pdf has changed diff -r 87b9e3e2c1a7 -r ec9773fe1dc0 cws/cw01.tex --- a/cws/cw01.tex Tue Oct 29 14:12:24 2019 +0000 +++ b/cws/cw01.tex Tue Oct 29 14:34:51 2019 +0000 @@ -15,8 +15,8 @@ \noindent This assignment is about Scala and worth 10\%. The preliminary -part is due on \cwSIX{} at 16pm, and the core part on \cwSIXa{} -at 16pm. You are asked to implement two programs about list +part is due on \cwSIX{} at 4pm, and the core part on \cwSIXa{} +at 4pm. You are asked to implement two programs about list processing and recursion. The core part is more advanced and might include material you have not yet seen in the first lecture. \bigskip @@ -143,7 +143,7 @@ $1$ Million. \hfill[2 Marks] \item[(2)] Write a second function that takes an upper bound as - argument and calculates the steps for all numbers in the range from + an argument and calculates the steps for all numbers in the range from 1 up to this bound (the bound including). It returns the maximum number of steps and the corresponding number that needs that many steps. More precisely it returns a pair where the first component is the number @@ -246,9 +246,9 @@ (first line), 2011 (second line) and 2012 (third line) you obtain: \begin{verbatim} - List(List(Some(312.204773), Some(26.782711)), - List(Some(301.0466), Some(41.244694)), - List(Some(331.462585), Some(51.464207))) + List(List(Some(311.349976), Some(20.544939)), + List(Some(300.222351), Some(31.638695)), + List(Some(330.555054), Some(39.478039)))) \end{verbatim}\hfill[1 Mark] diff -r 87b9e3e2c1a7 -r ec9773fe1dc0 solutions1/collatz.scala --- a/solutions1/collatz.scala Tue Oct 29 14:12:24 2019 +0000 +++ b/solutions1/collatz.scala Tue Oct 29 14:34:51 2019 +0000 @@ -1,4 +1,4 @@ -// Part 1 about the 3n+1 conjecture +// Basic Part about the 3n+1 conjecture //================================== // generate jar with diff -r 87b9e3e2c1a7 -r ec9773fe1dc0 solutions1/drumb.scala --- a/solutions1/drumb.scala Tue Oct 29 14:12:24 2019 +0000 +++ b/solutions1/drumb.scala Tue Oct 29 14:34:51 2019 +0000 @@ -1,7 +1,12 @@ -// Part 2 and 3 about a really dumb investment strategy -//====================================================== +// Core Part 6 about a really dumb investment strategy +//===================================================== + -object CW6b { // for purposes of generating a jar +// generate jar with +// > scala -d drumb.jar drumb.scala + + +object CW6b { //two test portfolios