Open garveychan opened 2 years ago
(sidenote: you can generate all the names within about 3 seconds, if you take care of not generating collisions)
If I understand correctly, you're reporting the following things:
Yep, that's right. My main concern with the regex quick fix is that it may distort the timeout validation when the solution is submitted online (I'm unfamiliar with the inner workings). I'll experiment with other options when I can find some more time.
Edit - I should clarify, the successful test case in the notes above (>11000ms) is bobahop's solution which hits <200ms without the regex test.
Ah. Understood, thank you for that clarification. Want to post the regex test change you made? I can probably help you optimise the regex to make it faster.
all the names can be generated
test, so the timeout won't be that much of an issue anymore.I took the existing regex test and put it into the loops where new robots were instantiated - on lines 68 and 137.
Sad. That's already pretty much as optimal as we can get. I'll figure out if there is a way to still test each and every name...
Yeah I've been trying to think of a way to validate names that wouldn't expose a solution in the test file haha. Thank you for looking into it.
I have thought of a way to implement this, so I will.
Issue
The top-ranked solutions for 'Robot Name' in Typescript are currently passing all unit tests even though (and primarily because) they are generating names that do not conform to the problem specification.
While the tests interpret these names as 'unique' because they do not exist within their respective Sets, repeating the regex check for each 'new name' function invocation exposes these strings as invalid robot names.
2nd Solution
3rd Solution
Notes
<200ms solution
Quick Links
https://github.com/exercism/typescript/blob/main/exercises/practice/robot-name/.docs/instructions.md https://github.com/exercism/typescript/blob/main/exercises/practice/robot-name/robot-name.test.ts https://exercism.org/tracks/typescript/exercises/robot-name