Skip to content

Commit

Permalink
review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
glennj committed May 10, 2024
1 parent d35becd commit 96a6b13
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
1 change: 0 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -1842,7 +1842,6 @@
"results"
],
"prerequisites": [
"custom-types",
"recursion"
],
"difficulty": 9
Expand Down
15 changes: 13 additions & 2 deletions exercises/practice/zebra-puzzle/.meta/example.gleam
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
import gleam/dict.{type Dict}
import gleam/list
import gleam/result

pub type Solution {
pub fn water_drinker() -> Result(String, Nil) {
solve()
|> result.map(fn(solution) { solution.water_drinker })
}

pub fn zebra_owner() -> Result(String, Nil) {
solve()
|> result.map(fn(solution) { solution.zebra_owner })
}

type Solution {
Solution(water_drinker: String, zebra_owner: String)
}

Expand All @@ -11,7 +22,7 @@ type Parameters =
type Nationalities =
Dict(Int, String)

pub fn solve() -> Result(Solution, Nil) {
fn solve() -> Result(Solution, Nil) {
solve_for_colour(
houses()
|> list.permutations(),
Expand Down
6 changes: 3 additions & 3 deletions exercises/practice/zebra-puzzle/src/zebra_puzzle.gleam
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub type Solution {
Solution(water_drinker: String, zebra_owner: String)
pub fn water_drinker() -> Result(String, Nil) {
todo
}

pub fn solve() -> Result(Solution, Nil) {
pub fn zebra_owner() -> Result(String, Nil) {
todo
}
14 changes: 7 additions & 7 deletions exercises/practice/zebra-puzzle/test/zebra_puzzle_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ pub fn main() {
test_runner.main()
}

pub fn puzzle_test() {
let assert Ok(solution) = zebra_puzzle.solve()

solution.water_drinker
|> should.equal("Norwegian")
pub fn drinks_water_test() {
zebra_puzzle.water_drinker()
|> should.equal(Ok("Norwegian"))
}

solution.zebra_owner
|> should.equal("Japanese")
pub fn owns_zebra_test() {
zebra_puzzle.zebra_owner()
|> should.equal(Ok("Japanese"))
}

0 comments on commit 96a6b13

Please sign in to comment.