6 kyu
Semi-Thue Systems - The Word Problem [Part 1]
50Dr Gabo
Loading description...
Mathematics
Algorithms
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
There should be test cases with overlapping occurrences of the left hand side of a rule, e.g.:
otherwise this kind of solution can pass.
Missing an edge case test with
from_str == to_str
.Added a test case to check that and modified my solution.
warning with your random tests: currently, the expected outputs aren't random at all => you need to build them differently, otherwise this kind of solution can pass
That's something I never thought about :/. I will randomize that as well.
Done!
EDIT: missing sample test: something with two rules where the initial string of one is a substring of the other, like
('ab',...), ('abc',...)
, and where you need to pick the second rule to get to the expected output.As a clarification, you can have two rules with the same left handside, so a dict might not be the best. I will modify the description and make more robust tests later. Thank you for your structured issue :)
ok, then you have another problem: this is never happening in the tests, apparently!
The tests now are much more robust and can filter out all the wrong solutions you gave me. Also, the description has been clarified.
errr... I don't see the new smaple tests (saw the shift to the new framework only / And you could update the test case to the new framework too...)
My bad, I forgot to add the tests to the samples :S (and I shifted the rest of the tests now).
Hi,
Plz, use the new python test framework. It makes the test suite far more readable.
Done too!
you forgot to remove one
test.describe('Random tests')
in the test cases partIs it intended to have only the first occurance of rule (in the string) replaced? Take this test for example:
My solution would fail that, but it clearly looks valid. There should be more tests for such cases or description altered to clarify this (bad idea IMO)
To apply a rule means to substitute one of the occurences (not necessarily the first one). So to go from 'aba' to 'abc' you need one application and to go from 'aba 'to 'cbc' you need two:
I will modify the description to clarify this fact.
That's all well and good, but that means my flawed solution passed all tests, which is an issue =/
That's because it seems like I forgot to add random tests with non-exhaustive rule applications. I will add them later :)
advise: unpublish your kata in the meantime, then. ;)
Needs better random tests, my solution should not pass.
The rules in the random tests happened to be too structured. A randomization did the trick. Thank you for your time.