admin管理员组文章数量:1122832
Just had a course where my teacher used this code, so i copied it to try it on pycharmcommunity and its says unresolved reference for helper_predicates, is_sorted, all_lte_all and is_permutation. When he used this code in class it worked perfectly, can someone explain if helper_predicates exists as a built in module or if I have to install something?
from helper_predicates import *
import random
def lusinvariant(values, orig_values, i):
return is_sorted(values[:i]) and \
is_permutation(values, orig_values) and \
all_lte_all(values[:i], values[i:])
def minimum_position(values, start):
minPos = start
i = start + 1
assert lte_all(values[minPos], values[start:i])
while i != len(values):
assert lte_all(values[minPos], values[start:i])
if values[i] < values[minPos]:
minPos = i
i += 1
assert lte_all(values[minPos], values[start:i])
assert lte_all(values[minPos], values[start:i])
return minPos
# Hint: def selection_sort_recursive(values, start)
def selection_sort(values):
orig_values = values[:] # enkel nodig voor lusinvariant
i = 0
assert lusinvariant(values, orig_values, i)
while i != len(values):
assert lusinvariant(values, orig_values, i)
minPos = minimum_position(values, i)
values[i], values[minPos] = values[minPos], values[i]
i += 1
assert lusinvariant(values, orig_values, i)
assert lusinvariant(values, orig_values, i)
# Test
lst = list(range(20))
random.shuffle(lst)
print(lst)
print("Iteratief:")
# Hint: selection_sort_recursive(kopie, 0)
selection_sort(lst)
print(lst)
本文标签: pycharmhelperpredicates module on python not foundStack Overflow
版权声明:本文标题:pycharm - helper_predicates module on python not found - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736309251a1933953.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论