Last active
February 8, 2021 12:15
-
-
Save radupotop/46d2007053568a0b64a998b9bcad78d4 to your computer and use it in GitHub Desktop.
Hypothesis play around
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from hypothesis import given, strategies as st | |
def q(list): | |
"""Quicksort""" | |
return [] if list==[] else q([x for x in list[1:] if x < list[0]]) + [list[0]] + q([x for x in list[1:] if x >= list[0]]) | |
@given(st.lists(st.integers(min_value=-10000, max_value=10000))) | |
def test_qsort(int_list): | |
print(int_list) | |
assert q(int_list) == sorted(int_list) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output