Compute a way to order a given set of dominoes in such a way that they form a correct domino chain (the dots on one half of a stone match the dots on the neighboring half of an adjacent stone) and that dots on the halves of the stones which don’t have a neighbor (the first and last stone) match each other.
It is said that I need to compute the correct domino chain, but in fact the exercise only requires to make a method that return a bool value - that is, if it’s possible to create such a domino chain.
So either the instruction needs to be updated, or the whole exercise needs to be updated to meet the instructions.
You need to create a chain to determine if creating a chain is possible or not. The details of the function’s return value are part of the fine details of the functions signature, which is encoded in the test details. The general overview of the exercise is correct that you need to create a chain to solve this exercise.
The prose describes the generalities. The tests encompasses the technical specs.
Well, I don’t need to create a chain to determine if it is possible to create a chain. That is, I solved the problem without actually creating a chain, so that’s not really true
I’m intrigued. How did you determine if it is possible to chain the dominos without chaining them?
It is very simple: the same numbers on dominos are always paired together in a chain, that means that there is an even number of sides of dominos with each number of dots (even number of ones, even of twos, etc.)
What I did is just checked if there is even amount of each number of dots, and if every distinct number of dots that is present in a domino set can be reached from any (from the first) domino.
I cannot prove that if there’s even amount of each number of dots and every distinct number can be reached from any other then it is guaranteed that there will be a chain, but it passed the tests on exercism and I couldn’t come up with a test case that would satisfy the requirements and would not create a chain.
if every distinct number of dots that is present in a domino set can be reached from any (from the first) domino.
So you check that there is a path from the first domino to all other dominos. That sorta sounds like building a chain
The expectation of this exercise is to build a chain. I can’t think of a counterfactual so it does sound like you found a clever work around to avoid actually building the chain. Most solutions do build chains to determine if a chain is possible. The instructions do intentionally guide you towards building a chain and that is the intent. There’s nothing wrong in the instructions. The tests do test the outcome which apparently can be worked around, but largely work as intended here.
Blockquote So you check that there is a path from the first domino to all other dominos. That sorta sounds like building a chain
Not really. I check it by having a bool array consisting of 7 elements, where array[i] = true means that a number of i dots can be reached. I just set the values at indices of the starting domino to true, and iterate over every domino and if either side of it is true in the array, the the other one is also set to true.
An btw, I think I found a way to prove that it works. It can be easily proven with the euler’s path theorem.
That’s a path finding algorithm, right? And a chain is a path. You’re not quite computing a chain but you are proving the chain can be built. You are correct that the tests don’t force you to build the chain and only ask that you check if a chain can be built. The instructions do encourage and direct you to build a chain. The intention is for you to build the chain.
I think we can to continue to encouraging students to build the chain. However, updating the tests has drawbacks.
Yeah, you are quite right about that one. I don’t think it would be worth to update the tests due to the potential consequences. The issue isn’t quite big so It might be worth to leave it as it is