Skip to content

Sorting an empty iterable throws an error #124

@cooljoseph1

Description

@cooljoseph1

Minimal reproducible code:

# bot.py
def turn():
    x = sorted([])

When trying to sort an empty iterable, the engine throws a ValueError:

File "C:\Users\camac\AppData\Local\Programs\Python\Python36\lib\site-packages\battlehack20\engine\container\runner.py", line 218, in do_turn
    exec(self.locals['turn'].__code__, self.globals, self.locals)
File "bot.py", line 2, in turn
File "C:\Users\camac\AppData\Local\Programs\Python\Python36\lib\site-packages\battlehack20\engine\container\instrument.py", line 14, in instrumented_sorted
    cost = len(iterable) * int(math.log(len(iterable)))
ValueError: math domain error

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions