Day 16 / Mar 22 (Tue)¶
Warm-Up Exercises¶
All Coordinates¶
Write a function that takes 8 uppercase letters (from A to H) and 8 numbers (from 1 to 8) and returns all the possible 64 coordinates (A1, A2,..., A8, B1,...).
Review a solution in solutions/all-coordinates.sc
.
Corner Half¶
Change the above function to return one of the two "corner" halves.
Review a solution in solutions/cornerHalf.sc
.
Word Occurences¶
Write a function that reads a file and prints out word stats: all the words and their occurences.
Review solutions in solutions/wordOccurences.sc
.
Type Aliases¶
Read up on the topic in Type alias:
Type aliases should be used instead of subtyping, when this subclassing does not actually extend the original type.
case class Occ(n: Int)
type Occurence = Int
type Word = String
With the above type aliases, you can define a return type to be Seq[(Word, Occurence)]
.
collection.Map¶
Learn more in the following resources:
Pair Programming¶
Use Pair programming technique and our randomPairs
polymorphic method to work together on a solution to the exercise.
File Stats¶
Write a function that reads a file and prints out the file statistics based on one of the following command-line options:
-
--words - All the words and their occurences
-
--lines - All the lines and their length (number of characters, incl. whitespaces), the number of words, and the words themselves (as a comma-separated sequence or similar)
Schedule¶
- 8:30 - 10:15
- 15' break
- 10:30 - 11:50
- 12:45pm - 1:40pm
- 1:50pm - 2:30pm