Ad
  • Custom User Avatar

    Somnetime you have write a program that pukes out data, see if you can see a pattern. So you can write a shorter program.

  • Custom User Avatar

    I like these is...Valid variables so much. But also, I think the early return of -1 and getting rid of 'else' would enhance the readability of this code.

  • Custom User Avatar

    Perfectly explained for everyone!

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    don't waste your time..

    I really don't want to be harsh but it may not be clear to those not in the know that this is a really really horrible solution.

    1. modifying the input, which is bad practice.
    2. while loop makes no sense.. a better terminal condition, if he is going to continue using splice and modifying the original data: while(data.length > 0). I'm going to assume that he just gave 25 so that his loop would iterate answers up to 25 bytes long.. his solution will always iterate at least 25 times, and for data with more than 25 bytes, his solution is not guaranteed to work.
    3. At this point, (for one of the test case scenarios that is only 4 bytes long) he has an array that has 21 empty arrays in it, and 4 arrays with the actual data. He is reversing ALL of these (21 of which are unnecessary), and then using array.concat to squash the empty arrays and reduce them into a single final array.
  • Custom User Avatar

    Very clever.. don't do this at home.

  • Custom User Avatar

    Requirements specified input is guaranteed to always have 8 bits per byte. No need for data.length check.

  • Custom User Avatar

    I don't think "Clever" and "Best Practice" really express what something like displaying a performance rating would. If producing a performance metric is truly impossible (please hire more help??) then at least provide another upvote mechanism such as "Bad Practice".

    There isn't currently a way to convey quickly and clearly that a particular solution is bad practice. I understand the text of "They usually are not code that you would to put into production" but I would advise changing the wording to "Do not use this code in production" if you're not going to provide a better way for those learning to distinguish what should and should not be used.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Am I the only one thrown off by the use of parenthesis for the return?

    It's valid.. but weird and honestly the first time I've seen it in a very long time.

  • Custom User Avatar
  • Custom User Avatar

    Excactly. This comment should be permanently added into this solution.

  • Custom User Avatar

    This is much better than the top one.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution