From 23bf4c7a414b0e0c799e0a06e40b2983d7f3ee5b Mon Sep 17 00:00:00 2001 From: RustyRaptor Date: Thu, 17 Oct 2019 13:48:00 -0600 Subject: [PATCH] Finished Lab 6 --- lab6/lab6.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/lab6/lab6.py b/lab6/lab6.py index 170114d..0fe23a3 100644 --- a/lab6/lab6.py +++ b/lab6/lab6.py @@ -1,12 +1,11 @@ -n = int(input("Please enter the value of n: ")) -Y = list(range(1, n + 1)) +Y = list(range(1, int(input("Please enter the value of n: ")) + 1)) -def function_generator(target): +def function_generator(targ): num = 0 - for anum, a in enumerate(target): - for bnum, b in enumerate(target): - for cnum, c in enumerate(target): + for a in targ: + for b in targ: + for c in targ: num += 1 yield (a, b, c, num) @@ -22,42 +21,43 @@ def is_1to1(a, b, c): return False -def is_onto(a, b, c, target): +def is_onto(a, b, c, targ): output_set = {a, b, c} - target_set = set(target) + targ_set = set(targ) - if len(target) > 3: + if len(targ) > 3: return False - if output_set == target_set: + if output_set == targ_set: return True else: return False -def is_biject(a, b, c, target): - if is_onto(a, b, c, target) and is_1to1(a, b, c): +def is_biject(a, b, c, targ): + if is_onto(a, b, c, targ) and is_1to1(a, b, c): return True else: return False -def get_truths(a, b, c, target): - return is_1to1(a, b, c), is_onto(a, b, c, target), is_biject(a, b, c, target) +def get_truths(a, b, c, targ): + return is_1to1(a, b, c), is_onto(a, b, c, targ), is_biject(a, b, c, targ) -def print_funcs(target): +def print_funcs(targ): count_oto = 0 count_onto = 0 count_bi = 0 - for i in function_generator(target): + for i in function_generator(targ): a, b, c, num = i - oto, onto, bi = get_truths(a, b, c, target) + oto, onto, bi = get_truths(a, b, c, targ) if oto: count_oto += 1 if onto: count_onto += 1 if bi: count_bi += 1 + print("=" * 10, "FUNCTION", num, "=" * 10) print( numstr(num, "a") + str(a), numstr(num, "b") + str(b),