7 kyu

Steve jumping

Description
Loading description...
Fundamentals
Algorithms
  • Please sign in or sign up to leave a comment.
  • sid114 Avatar

    missing it blocks in sample tests

  • JamakaDev Avatar

    How in the world is (10-3.5)*(1-0) equal 2.5 in the example?

    DMG = max(0, (DISTANCE - 3.5) * (1 - DMG_REDUCTION))

    ['10 D', '4 D', '0 D'] --> 'jumped to the end with 18 remaining HP' #DMG_1 = 2.5 -> 2, DMG_2 = 0.5 -> 0

  • ejini战神 Avatar

    N cannot be less than 2.

    Description does not mention what does N represent. Based on my assumption, it's the size of the array, then you should specify clearly!

    Also, in & out should be input & output

  • Blind4Basics Avatar

    Hi,

    Issue part:

    • the description is inconsistent about DMG_REDUCTION: in the formula, it's a value between 0 and 1 while they are given as percents just below
    • if you give the formula to compute the damages, it must be "right", meaning you should talk about the rounding when you give the formula, not as a "note" in the rules section, 10 lines below.
    • the first fixed test of the full test suite should be added to the example tests
    • the test module and the user's function should be imported explicitly (full test suite + example tests / see documentation if needed)
    • Replace the task part with:

    Write a function, that returns the outcome for Steve:

    • if he survives, it retruns 'jumped to the end with X remaining HP', where X is the remaining HP at the end of the array.
    • If Steve dies, return 'died on I', where I is the index of the jump he dies
    • In the rules section:

    All inputs is are valid according to the rules.

    Suggestion part:

    • In the second batch of random tests, Steve almost never dies. Not a problem, because the balance is good in other batches, but if you can get better average...
    • Replace the first sentence with:

    Steve, from minecraft, is jumping down from blocks to blocks and can get damages at each jump. The goal is to know if he survives his descent or not.

    You are given a list of blocks as strings, in the format "BLOCK_HEIGHT BLOCK_TYPE". Steve jumps from one block to the next, and get damages calculated with the following formula: ...

    • about the code, if you use lists of data in the fixed tests, you should build those data with everything you need to do the all tests with a loop, wrting the assertion one time only ('will need that you store input and related output in the cases list). Otherwise, there is no point to that list and you could write all the assertions without it.

    Cheers

  • Voile Avatar

    The input format is not very well specified. What is the data type of BLOCK_HEIGHT and BLOCK_TYPE? It's not clear whether BLOCK_HEIGHT is always integral or always non-negative, or what possible values for BLOCK_TYPE is (the damage reduction part did not say what those are, or made any connection from these values to other parts of the data).

  • Voile Avatar

    In fixed tests the array used for test block display is different from the input array. Perhaps you should really extract the test method into something like

    def do_test(input, expected):
        test.assert_equals(jumping(input[:]), expected, 'for {}'.format(input))
    

    so this wouldn't happen.

    Also, random tests break when input is modified.

  • Voile Avatar

    The damage formula as it's written is misleading at best: (DISTANCE - 3.5) is not the actual damage formula, that's the first step of the actual damage formula. max(0, (DISTANCE - 3.5) * MULT) would be the real damage formula. So I think it should be rewritten.

  • Voile Avatar

    The damage formula can return a negative value when distance is less than 3.5, but I don't see any mentions on the handling of this. Clearly jumping on equal ground should not give Steve more HP?

  • Unnamed Avatar

    Returning inconsistent data types is rarely useful. What is this result for? If it's for further processing, a string with a number inside would be inconvenient. If it's for output to the user, a number alone doesn't mean much and it would need to be stringified somewhere anyway.