-
-
Notifications
You must be signed in to change notification settings - Fork 546
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Robot Name Requirements #130
Comments
Hm, yeah, I see what you mean. We should clarify that. The original intention was to avoid collisions, but in tracks where there are no tests about that this might be more part of the discussion than part of the original requirement. |
Actually while we are looking at it, does it read to you that the randomness of the names is a requirement? Or would an acceptable solution (+1) iterate the names as a means to avoid collision? |
The way I read it randomness is a requirement, but you're right--this could be reworded to provide a broader range of acceptable approaches. |
Fixed in #131 |
@kytrinyx ... i took a quick look to see how other people implemented this. it looks like in many cases people just use either
I'm curious if this might be better served with another test to verify that a given random name is already in use (implying a name registry of sorts):
|
I'm not sure. It seems a bit awkward for the robot API to expose a method for checking whether or not a name is valid, but I do think that you're right that the problem becomes more interesting if we are able to ensure that names are not duplicated. |
The test(s) would have to be reformulated to track for that. While the robot generator would have to guard against duplicates it would be weird to have the generator prove each name is unique. I read the problem to indicate the the name had to be in the format LLNNN, which ends up limiting the total namespace. Fundamentally having to enforce randomness and uniqueness is tricky given the finite namespace. It would definitely make the problem harder to solve. It would also make the tests more complex and you would need tests that make an attempt to exhaust the available namespace to make a collision. It could be required that the generator signal exhaustion of the namespace. It gets complicated! In my JS solution I ended up throwing an error if the namespace was all used up and added a test to check for that condition. The uniqueness/randomness of the names could always be the style-points award, a place where solutions distinguish themselves in implementation rather than be an absolute requirement. |
@tleen I followed the JavaScript one in the C++ track. I have one test that verifies that the letter prefix changes when the digits are exhausted, I think. I didn't want to write a test that tried to verify that all generated names were unique by exhaustively generating all the names and then checking them for uniqueness. To me, it made more sense to assert this by induction in the tests. |
We should keep in mind this is just an exercise, don't want to make the tests too burdensome. |
Yes, I agree. I don't think gold plated engineering is the point of exercism. I've seen some of that in the C++ track where people are thinking that the point of the exercise is to create the most bulletproof thing you can possibly imagine. My point of view is to take the problem statement as a general guide and then use the tests to guide what my implementation should do. If the test doesn't require me to do something, then I view that as not required 😸. |
I'm finding the uniqueness requirements of the robot name task unclear.
Does this indicate that collisions should be avoided in every environment or just in those with tests specifically disallowing collisions?
The text was updated successfully, but these errors were encountered: