Ad
  • Custom User Avatar

    Added into description that an empty sequence of action should result in 0 dps.

    I chose 0, as technically, doing no actions should result in 0 damage, but it isn't illegal to do nothing.
    But if I were to add some invalid/unexpected characters in string, a None or exception would be a good return value.

    Made a function that loops and generate random test cases.

  • Custom User Avatar

    Thanks, edited the description to more precisely indicate what would happen when shooting with less than 20 energy

  • Custom User Avatar

    Made a function that loops and generate random test cases.

    Made charging/shooting random lengths.

  • Custom User Avatar

    Thanks for your recommendation! I don't speak Javascript, but maybe I'll learn it later and give that one a shot.

  • Default User Avatar
    • You can consolidate random tests inside a single for loop instead of duplicating similar code.
    • Only "Charging" and "Shooting" can be tested with varying random lengths.
  • Custom User Avatar
  • Custom User Avatar

    Fun kata imo.
    I think that it should be a little more clear that the gun cannot shoot with less than 20 energy. I initially made the assumption that if the gun had energy, it could shoot. Say for example, when the gun has 15 energy. The only clarification is in the "special considerations" where it says that the gun cannot shoot with 0 energy. I think after some trial and error, this is easy to solve, but this clue can be misleading.

    Can't wait to see the sequel to this! I can imagine an expansion of this kata where you give him an array of actions to simulate multiple encounters.

  • Custom User Avatar

    Yes, but

    • an exception (or None) is better
    • it should be stated in description
  • Custom User Avatar

    The average of an empty sequence is undefined, not 0.

    Yes, but it can depend on the situation. I think in this case 0 is acceptable.

  • Custom User Avatar
    • The average of an empty sequence is undefined, not 0.
    • Only 3 random tests.