Skip to content

Conversation

petertseng
Copy link
Member

Closes #139

More detail in individual commit messages.

Sidebar: It could be the case that only the last commit is necessary - is there an input and output pair for which the consecutive-dominoes check and same-dominoes check hold, but the dominoes-at-ends check doesn't hold? Can't think of one. Nevertheless, I include the commit for completeness.

let check_chain (input: dominoe list) (chained: dominoe list) =
let assert_dominoes_match d1 d2 =
if snd d1 <> fst d2 then failwith @@ sprintf "%s and %s cannot be chained together" (print_dominoe d1) (print_dominoe d2) else () in
let consecutives = List.zip_exn (drop_1_right chained) (List.tl_exn chained) in
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or maybe I can change this to List.zip_exn chained (List.tl_exn chained ++ [List.hd_exn chained]), so that the list of consecutives will include (List.last_exn chained, List.hd_exn chained)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

decided I might as well do that.

Otherwise, unconditionally returning `Some [(1, 2)]` unreasonably passes
many tests (7/12, all tests expecting a `Some`).

With this commit, they will fail with:

    (Failure "(1,2) and (1,2) cannot be chained together")

As part of the work in #139.
Otherwise, unconditionally returning `Some [(1, 1)]` unreasonably passes
many tests (7/12, all test expecting a `Some`).

With this commit, they will fail with:

    chain doesn't use the same dominoes as the input
    expected: [(1,2);(1,3);(2,3)] but got: [(1,1)]

Closes #139
@stevejb71
Copy link
Contributor

These changes make sense.

@stevejb71 stevejb71 merged commit 10a4e11 into exercism:master Jan 25, 2017
@petertseng
Copy link
Member Author

Oops, I should have updated the template as well, sorry for making you have to do it in #141! I'll leave this as a reminder for myself for next time.

@stevejb71
Copy link
Contributor

That's cool. It was only a couple of minutes' work to fix up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants