Ad
  • Custom User Avatar

    You cannot, that's true. But this is a dojo here... and the kata should give you an insight.
    btw: In Karate you won't defend yourself running a kata (e.g. Empi or Unsu) when you gonna beaten up by some rude guys.

  • Custom User Avatar

    Well, it does not need more, but better test cases, like using special char words... as described in instructions. The random test case generator is a nice thing, but not very productive and not comprehensive. WOuld be much better to test exactly what's written in the instructions. Nevertheless, nice kata!

  • Custom User Avatar

    Improve the problems description, please. It should be possible to understand the problem without reading the testcase first. User 'kristaps' already proposed a suggestion.

  • Custom User Avatar

    Quite nice. I like performant solutions. And this one is a good example where one can find advantages and drawbacks. Usually, it is like this: Performant solutions lack readability and are more difficult to understand. Less performant solutions have other advantages, like they are more comprehensive for others, or they are better encapsuled in their context, are reusable, are testable, etc. etc. Of course, the latters no count for this specific algorithmic problem. But your solution reveals something interesting, which I knew from earlier experiments: pure for-loops are much faster, than forEach, filter and other iterator functions. The iterator functions abstract the underlying structures which comes of the cost of some additional overhead, but those solutions are easy to use and understand. In other languages (p.e. Java, C++, C#) those abstractions are used for generic data structures which comes very handy - and it is elegant!

  • Custom User Avatar

    Thanks for feedback. I considered your suggestion and applied it. There's no special reason why I chose 'expect'. IMHO the code sounds slightly more natural with test.expects() than with test.assertEquals().

  • Custom User Avatar
  • Custom User Avatar
  • Custom User Avatar

    Fixed. It says "Assert: a1=1" instead of "Assert: a1===1".

  • Custom User Avatar

    What about .234.56.73 and -123.45.67.89?
    I know your solution passes, but only because the test specification is lacky. Hence, not your fault ;)

  • Custom User Avatar

    I suggest to test also IPs like

    -123.34.56.-2

    .4.4.6

    232..34.2

    Whitespace should not invalidate an IP address in my opinion.

    @svol Conforming RFC3330 0.0.0.0/8 are valid IPs.

  • Custom User Avatar
  • Custom User Avatar

    Thx and full Ack. The core question is: What defines a good solution?
    This can be a polemic discussion...but hopefully not like Android vs iOS or Amiga vs Atari :D

  • Custom User Avatar

    Well, obviously my intention was misunderstood. Since I started to train here I learned a lot. I don't post the perf comparisons to make others worse. I am far away from being a good coder and I am always impressed by the solutions provided here.

    I also think sometimes a communities favorite solution has one or more drawbacks which may not be obvious. And posting JsPerfs can reveal some hints about it. These kinds of 'drawbacks' can be measured and presented in an objective manner. Inspecting solutions and comparing them considering different aspects is a very good way to learn (at least for me).

    Like "Uncle Bob" I train some katas several times to see if I can find another probably better solution. This is the real deal of a kata...try to perfect it by inumerous repetition.

    Sorry, If you felt (or others) offended. This was not my intention.

  • Custom User Avatar

    The idea of the kata is nice. But the description is misleading or at least the tests are too easy to pass. An FSM is quite easy to implement, if it would be only about state transitions. As a class-like definition was provided I expected a more sophisticated OO-like solution. Most people won't follow the concept of a more generic automaton.

    As it can be solved easily I tend to suggest a --rank !

    Ooops, am I repeating @nooga? ;)

  • Custom User Avatar

    Opa.... vlw pelo upvote! Did you see my tuned version already...?

  • Loading more items...