Ad
  • Default User Avatar

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

  • Default User Avatar

    The underlying expression of your statement is incorrect, because this function will be implemented into other code and so this function will be executed an unknown number of times per second. Always keep that in mind :) .

  • Default User Avatar

    Thanks, this is really sad. Maybe i will create my own platform like this here then, just with much less bugs and proper core-features.
    The github feature-request is over 2 years old. If a platform isn't capable to implement such a core feature after even 2 years, this is not a good sign and so maybe this platform will be going down at some point :/

  • Default User Avatar

    This has to be a joke. Are you a developer/maintainer from codewars or just some user?

    I doubt that a modern (looking) website, that is about "coding", lacks the ability to set profile images and then doesn't even generate random images like github.

    Is this feature really not existing here? If so: Why?

  • Default User Avatar

    Very hard to read, to understand and to maintain. This code should never be used in production.

    You should definitely refactor your code.

  • Default User Avatar

    Very very hard to maintain and to read. You should refactor your code.

  • Default User Avatar

    For me it correctly returns "10". I think you copied something wrong maybe?

  • Default User Avatar

    I 100% agree, but since upvoting replies does not work for me on codewars, have my reply.

  • Default User Avatar

    Just did a benchmark myself, looping over 10.000.000 array-entries:

    for-of: 154.071ms
    for-in: 143.209ms
    for-each: 153.508ms
    for: 11.204ms
    

    From what i read, the forEach was drastically slower in previous node-versions. But since year or so at least, it is now on an equal level. But seems that, if you want performance, you should use the standard for-loop, because it's just way faster.
    But i also understand your opinion on the pure function part.

  • Default User Avatar

    Same solution as mine, but to add the missing 1%:

    • You can add to the directionValues the possible keys n, s, w, e.
    • Add return type to main function and the function you pass in the forEach.

    There are several people out there who say that forEach is bad, but i didn't verify any of those.

  • Default User Avatar
    • You are looping through the array multiple times, this is horrible performance.
    • The attribute-names you have chosen are not very easy to understand and not readable.

    You should refactor your code.

  • Default User Avatar
    • Performance is not very good
    • Readability and maintainability are also not good

    You should refactor your code and also only loop through the array once.

  • Default User Avatar

    Very interesting and creativ approach.

    But i think the performance is the same as just looping through the array once, counting the appearances for each orientation and at the end check, if n==s && e==w. And i think the approach i mentioned is way easier to understand and also to maintain.

    Edit: I think the solution i mendioned is even a fraction better on performance, but it's really more about readability and maintainability.

  • Default User Avatar
    • Performance here is horrible
    • Code is not good to maintain and not "clean code"

    You should think about refactoring your code.

  • Default User Avatar

    How can i change my profile image (without beeing forced to link some social accounts)?

  • Loading more items...