Skip to content

Day 22 / Mar 30 (Wed)

Morning Exercise: Sum Element Every N Numbers

Write a function that checks if every two, three, n numbers in a sequence are followed by their sum.

def isSumAfterN(n: Int, ns: Seq[Int]): Boolean = ???

Write tests first (using ScalaTest test framework).

Code Review

An interactive session that demo'es the following:

  1. How to use GitHub for collaborative development
  2. git on command line
  3. Code refactoring with test support (sbt test and IntelliJ IDEA)
  4. Contribute to a project using pull requests

Pair Programming

Pair programming

Calculator Again

Create a command-line application that reads a file with a series of math operations (one on each line) and gives the total at the end.

The following operations are supported:

  1. + (sum)
  2. - (subtract)
  3. * (multiply)
  4. / (divide)
  5. - (negation) (WARNING: The same symbol with subtraction)

The application should suppport PRINT operation that prints out the current total to the standard output (stdout) when it appears in a operation file. There can be zero, one or many PRINT commands.

Operation file should support comments (as lines starting with # or //).

A sample operation file:

# + 4 5
- 8
+ 5
-
PRINT
- 7
PRINT
PRINT
/ 2

Working in pairs1:

  • (daniel,leo)
  • (ania,krzysiek)
  • (damian,janek)
  • (rafal,adam)
  • (grzegorz,mateusz)

Schedule

  1. 11:45 - 12:30 Lunch break
  2. 12:30pm - 1:35pm
  3. 1:40pm - 2:30pm

  1. The story, all names, characters, and incidents portrayed in this production are fictitious. No identification with actual persons (living or deceased), places, buildings, and products is intended or should be inferred. (cf. All persons fictitious disclaimer

Back to top