4 kyu

Anakin's Colorful Protocol Droids

Description
Loading description...
Puzzles
Riddles
  • Please sign in or sign up to leave a comment.
  • typeError92 Avatar

    This comment has been hidden.

  • sizick Avatar

    This comment has been hidden.

    • typeError92 Avatar

      See my comment on your solution and the issue raised in the discussion board - yes, this passes the tests, but I'd argue that this just means that the tests aren't doing what they should ;)

    • deckar01 Avatar

      The migration from the old expect utility to chai introduced this regression. I'm surprised there aren't any safeguards for expect calls that are never completed. There were a few other no-op expect calls that this report uncovered. Thank you.

      P.S. I initally reported this comment, because it read like a person just copying their solution into chat. In the future please mark the comment as an issue and reference the submission without publicly pasting the code.

  • dfhwze Avatar
    • dfhwze Avatar

      Different enough, I guess. Approved at lowest rank available. Votes were really all over the place this time.

  • HartlIKS Avatar

    Is there a list of possible color values somewhere? Or do our solutions have to be able work with arbitrary strings for color names?

  • Voile Avatar

    The security measures are too overblown: it's even suppressing console.log. How're we supposed to debug the steps with this?

    Either console.log should be piped back to the main process, or there should be some non-sandboxed fixed tests that can actually be debugged. Random tests could also show what colors are assigned to each bot.

    • deckar01 Avatar

      console.log works fine while testing and is not intended to be available during an attempt. I don't think this is uncommon for sandboxed kata, and it does not appear to violate any of the authoring guidelines.

      Errors provide messages and reference the offending line. Combined with the test titles, the information should be sufficient for users to build their own test cases to reproduce any failures.

      Issue marked resolved by deckar01 16 months ago
    • dfhwze Avatar

      If you disable console.log, you should provide an additional sample test with more than 2 colors.

    • deckar01 Avatar

      @dfhwze What purpose would that serve? Logging works for user tests.

    • dfhwze Avatar

      How do you suggest users write tests if they don't know (yet) which are correct test cases? This kata is a total black box.

    • deckar01 Avatar

      Any test case you choose is valid as long as there are two of each color, as mentioned in the description. The example tests are trivial to modify, run, and log/debug.

      In the real world you don't always have logging for a production system, and I'm ok with this kata being difficult if that teaches people how to think critically and learn how to write repro tests.

    • dfhwze Avatar

      Oh I see, sample test does not check on valid "hint" given by Anakin. Then it would be easy for users to write own test cases.

    • deckar01 Avatar

      I don't believe this is necissary. The example test is just for developing the algorithm. Everything else in the full test suite (like hint validation) is for cheat prevention and has clear error messages.

  • Voile Avatar

    There are a lot of testing code and security features but no actual descriptions mentioning how the process is actually done, so it's very hard to know what is even being tested.

    • deckar01 Avatar

      Thank you for taking the time to review this kata.

      Coming back to this with fresh eyes, I agree that the description is light on specifics. I put a most of the technical details in the comments of the solution template.

      Do you think it would help if I inlcuded pseudo code in the description that outlined the testing procedure and provided an example to demonstrate the event API?

    • Voile Avatar

      Yeah, It's really needed. I don't even know how the 3 functions are called in sequence, and it's all really confusing.

    • deckar01 Avatar

      I added an example to help demonstrate the order of events and API documentation for the class interfaces. I hope that helps. Let me know if you run into any issues. Thanks again for your feedback.

    • deckar01 Avatar

      Resolving due to inactivity.

      Issue marked resolved by deckar01 16 months ago
  • CIS 122 Avatar

    I think my solution is probably not what you had in mind. I'll leave it up to you to decide if this is something you want to prevent or not. Otherwise, nice use of sandbox!

    • deckar01 Avatar

      I previously commented that I am planning to add randomized tests which should thwart attempts to hard code the answers in the solution.

      Do you think randomized tests are sufficient?

    • CIS 122 Avatar

      Probably. I'll see if I can still cheat after you've added them ;)

    • deckar01 Avatar

      The tests get shuffled randomly now. Thanks for the feedback!

  • Balkoth Avatar

    I really like this kata, but there are a few things that can be improved:

    • You should say that the droid code will be sandboxed, because it is not the case for local tests and the weird error messages confused me at first.
    • Some ES6 features are not avalaible in this sandbox, such as Set and Spread operator. Arrow functions work though.
    • All log messages and test results concerning Droids appear at the bottom, making them difficult to associate with the test messages. I know it is because the Droid tests are run asynchronously, but if you could fix that it would improve the kata experience.
    • deckar01 Avatar

      Thanks for your feedback.

      • I will make it explicit that only the droid's prototype will be transferred to the sandbox.
      • I should be able to compile the droid with babel to replicate the ES6 support.
      • I definitely need to make these tests execute syncronously to clean up the output formatting.

      Thanks again! Let me know if you think of anything else.

    • deckar01 Avatar

      I added a section to the description that explains how the sanbox works. I also fixed the way that the Droid class is serialized so that its static properties are available in the sandbox.

      The tests now execute synchronously since I switched to using the vm module instead of a cluster.

      I have not cracked the ES6 support yet. The issue is that the Droid class has already been parsed by Babel in the test code, but the sandbox does not have access to the global polyfill functions that Babel injects. Some ES6 features work because they are transformed to pure javascript and don't require polyfills. My attempts to use require('babel/polyfill'); do not seem to inject the global functions properly.

    • deckar01 Avatar

      I tried to pass the Droid class using the vm sandbox, which allowed ES6 features again, but for the same reason global state was shared and cheating became trivial.

      Instead I inspected the GLOBAL object for functions injected by Babel and passed those into the sandbox. It's super hacky, but it seems to work.

      I beleive I have resolved all of your issues. Let me know if you think of anything else.

      Thanks for your feedback!

    • Balkoth Avatar

      Much better this way. Nice work!

  • deckar01 Avatar

    This is my first kata. Any advice would be greatly appreciated.

    I am planning to add some randomized tests.