Skip to content

Commit

Permalink
Merge pull request #3 from winitzki/feature/some_solution_for_chapter_2
Browse files Browse the repository at this point in the history
one more solution
  • Loading branch information
winitzki authored Nov 22, 2023
2 parents 4904374 + 8f6efc5 commit 58cdce0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ To reformat code, run the script:

`bash reformat_all_code.sh`

Run this command before pushing any code changes. If formatting is not applied, builds will fail.
22 changes: 22 additions & 0 deletions chapter02/src/test/scala/sofp/unit/Exercises_2_1_7.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package sofp.unit

import com.eed3si9n.expecty.Expecty.expect
import munit.FunSuite

class Exercises_2_1_7 extends FunSuite {

test("exercise 2.1.7.1") {

val allPairs =
(0 to 9).flatMap { i =>
(0 to 9).map { j =>
(i, j)
}
}
val filteredPairs = allPairs.filter { case (i, j) => i + 4 * j > i * j }

expect(filteredPairs.take(4) == Seq((0, 1), (0, 2), (0, 3), (0, 4)))
expect(filteredPairs.length == 64)
}

}

0 comments on commit 58cdce0

Please sign in to comment.