battlecode / battlehack20

🐍
https://bh2020.battlecode.org
GNU General Public License v3.0
12 stars 3 forks source link

Sorting an empty iterable throws an error #124

Open cooljoseph1 opened 4 years ago

cooljoseph1 commented 4 years ago

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