Ad
  • Custom User Avatar

    The example matrix transformations in the instructions don't match the unit tests.

  • Custom User Avatar

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

  • Custom User Avatar

    As for why so many people marked it as "Best Practice"... maybe they liked the variable names and spacing between lines?! Just kidding. I'm guessing they just didn't realize there was a better way. Or they exhibited mob behaviour - once it has a few upvotes others upvote to go with the crowd.

  • Custom User Avatar

    @sheriv, it's not one iteration. For each index he's checking he sums up all the numbers on the left and all the numbers on the right. He's forcing the CPU to do the same calculations over and over, and to solve this it's unnecessary. For example if you are at an index and already know the left and right sums at that point, you only need to remove one element and add one element to check the neighbouring index - but the solution above has the program recalculate the entire sum on both sides. It's functional but it's not elegant or efficient.

  • Custom User Avatar

    I think I did it the complex way, lol. But.. mine could easily be modified to work for any rotation of rectangle and any length of sides and it should still work. So there's that.

  • Custom User Avatar

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

  • Custom User Avatar

    I was going to reply with these same critiques but I see someone else beat me to it. Anything using streams tends to look clever but there's no excuse for calling the same function twice for the same values. It's even called here a third time for every number that's a factor.

  • Custom User Avatar

    And here I thought my solution was elegant. Noice!

  • Custom User Avatar

    Finally the same solution I found is the top one! All of the other problems I solved had solutions by other people that were way better, lol. I did go with the StringBuilder as others have mentioned but the difference is kind of trivial. That would just be an efficiency upgraded needed when dealing with larger datasets.

  • Custom User Avatar

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