Ad
  • Custom User Avatar

    If you used a loop {} construct instead of the for loop, you wouldn't need the unreachable (0, 0, false) case, since a loop {} that never terminates has the never type (!) which Rust can automatically coerce to any other type.

  • Custom User Avatar

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

  • Custom User Avatar

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

  • Custom User Avatar

    I'm having the exact same problem, my solution does work with 1 tho, my solution fails for the second test case, it just says "Value is not what was expected".

    From a Python interpreter session with my solution:

    >>> grade(0)
    'F'
    >>> grade(1)
    'A'
    >>> grade(0.7)
    'C'
    >>> grade(0.6)
    'D'
    >>> grade(0.5)
    'F'
    >>> grade(0.8)
    'B'
    >>> grade(0.9)
    'A'
    >>> 
    

    I don't see anything wrong with this.

  • Custom User Avatar

    On Python, you can check the function's code object: calculate.func_code.co_consts contains all constants (numbers) used in the code. A simple check would be if 2 not in calculate.func_code.co_consts: test.fail()