Pig Latin: Unclear Instructions

In the “Pig Latin” exercise, the instructions describe four rules, each of which transforms a word into another if the word satisfies certain conditions. The conditions of the rules are, however, not mutally exclusive. For example, “xray” satisfies the condition for rule 1, because it starts with “xr”, while it also satisfies the condition of rule2, as it starts with a consonant. The instructions should describe which rule should apply when a word satisfies the conditions of multiple rules. When I apply rule 4, rule 3, rule 1, and rule2 in this order, I could pass all the provided tests. But I see no reason why this should be the right order of application of the rules.

TL;DR: When the test say, “this is the order of the rules”, then that’s what your solution shall do.

Exercism in general follows the test-first principle. That means, the tests are the most precise specification of the problem. So sometimes there is some “more precise”, “new” or “unexpected” requirement in the tests. Nevertheless, tests also may not cover all possible edge cases or catch all kinds of “wrong implementation”.

In addition, any textual description in a natural language will be misunderstood by or unprecise to someone. So we tend to keep instructions short and readable instead of “complete” or “precise”. We do not want to have differences between instructions and tests, like contradicting rules - if you find that, please report it here.

2 Likes

Thanks for your reply. I understand your point. I actually like the test-first principle, which I often practice myself. I also agree with you that certain aspects of a problem/project can be precisely and concisely described through tests, rather than through verbal description. For example, tests can often do excellent jobs in describing how inputs are given and how outputs should be returned. I, however, do not 100% agree with you about the particular exercise. I think that it is quite irrelevant for the purpose of learning to try 4! = 24 possible order of rule applications and go through pretty lengthy outputs to find out the right one.

Best,

Borderite

@Borderite can you suggest some new wording for the instructions? That will focus this discussion.

It would seem to me that a sentence such as “Apply the rules in order of xyz” would make this all clearer. @Borderite do you agree?

@iHiD’s proposal sounds good to me.

There is no such “one correct order of rules”. I used rules 1, 4, 3, 2 as the order. Finding the correct order for fulfilling requirements often also is part of solving a problem.

And I don’t see the problem of having to “brute force” finding the solution. When the initial order didn’t work, I followed the path of the value in question through the program to see where it took the wrong path. That made it clear that the order of rules must change.

So at most I’d add a sentence like “The order of the rules may need to be changed to fulfill the requirements”.