5 kyu

Finite automation 2: NFA Runner

Description
Loading description...
Fundamentals
  • Please sign in or sign up to leave a comment.
  • aland97 Avatar

    approve or feedback?

  • dfhwze Avatar

    The link to the 3th chapter of this series points to the 1st one.

  • Blind4Basics Avatar

    missing fixed test: something like the following:

    Start states [ 8 ]
    Transitions [
      [ 0, 'b', 6 ], [ 0, 'b', 8 ],
      [ 1, 'a', 5 ], [ 1, 'b', 9 ],
      [ 2, 'b', 4 ], [ 2, 'b', 2 ],
      [ 3, 'b', 9 ], [ 3, 'b', 0 ],
      [ 4, 'a', 5 ], [ 4, 'a', 8 ],
      [ 5, 'b', 6 ], [ 5, 'a', 8 ],
      [ 6, 'a', 0 ], [ 6, 'b', 0 ],
      [ 7, 'b', 1 ], [ 7, 'a', 4 ],
      [ 8, 'a', 7 ], [ 8, 'b', 7 ],
      [ 9, 'b', 2 ], [ 9, 'a', 3 ],
      [ 1, '', 3 ],  [ 9, '', 3 ],
      [ 4, '', 9 ],  [ 3, '', 8 ],
      [ 3, '', 1 ],  [ 1, '', 3 ],
      [ 2, '', 8 ],  [ 3, '', 3 ]
    ]
    Aceppt states [ 0 ]
    input:     aa
    

    my solution fails often, but not on every run of the random tests (note: I don't know the expected result there, because my code ends up in a recursion error)

  • Blind4Basics Avatar

    Hi,

    • In the test suite, you should avoid to print actual info to the console. For instance, the logs you do in the random tests could actually be in the message of the it block. Well, I guess there is too much data to write in there... Maybe just remove the logs. If the user needs the infos, he can print them on his side. On the other hand, you could be a bit more precise about what's going on in the random tests, changing the message of the it block to something like X tests on a new NFA or something like that.
    • It would be better to separate the concerns in the random tests: so for you redefine the whole logic of the solution inside the loop defining the it blocks of the random tests. 'Would be better to have a separate function (defined in the describe block, but not right inside the for loop) that you call with the appropriate arguments. This way, the tests will be easier to maintain by others.
  • Blind4Basics Avatar

    Hi again,

    • at least in the sample tests: actual and expected are swapped.
    • description isn't better than the first one (except for the fact that now, I already know what it is about, sort of...)

    cheers

  • dfhwze Avatar

    See question below. Why this many tests? Is this an extreme performance kata?

  • dfhwze Avatar

    How many tests do you have? I'm timing out after 123,000 tests. Perhaps you should add a "performance" tag.