It is ok to post! # Name:Treasa Bency Biju Jose # Date: 09-18-2020 # Assignment #4 ------------------------------------------------------------------------------------------------------- I. CP({a, b, c}, {b, c, d}); {[a, b], [a, c], [a, d], [b, b], [b, c], [b, d], [c, b], [c, c], [c, d]} CheckMult({1, 2}, {3, 4}); true CheckDecomp({1, 2, 3}, {3, 4, 5}); {1, 2, 3}, {3, 4, 5}, have the following common elements , {3} FAIL member([d, o, r, o, n], Words({d, n, o, r}, 5)); true ------------------------------------------------------------------------------------------------------- II. n = 110 Maple sequence: seq(i,i=1..110) gives exactly 1 hit on OEIS ------------------------------------------------------------------------------------------------------- III. PIE2 := proc(U, A1, A2) local n, m; if not type(U, set) then RETURN(FAIL); end if; if not type(A1, set) then RETURN(FAIL); end if; if not type(A2, set) then RETURN(FAIL); end if; if A1 intersect A2 = {} then RETURN(FAIL); end if; n := nops((U minus A1) intersect (U minus A2)); m := nops(U) - nops(A1) - nops(A2) + nops(A1 intersect A2); print([n, m]); end proc: -------------------------------------------------------------------------------------------------------- IV. PIE3 := proc(U, A1, A2, A3) local n, m; if not type(U, set) then RETURN(FAIL); end if; if not type(A1, set) then RETURN(FAIL); end if; if not type(A2, set) then RETURN(FAIL); end if; if not type(A3, set) then RETURN(FAIL); end if; if (A1 intersect A2) intersect A3 = {} then RETURN(FAIL); end if; n := nops(((U minus A1) intersect (U minus A2)) intersect (U minus A3)); m := nops(U) - (nops(A1) + nops(A2) + nops(A3)) + (nops(A1 intersect A2) + nops(A1 intersect A3) + nops(A2 intersect A3)) - nops((A1 intersect A2) intersect A3); print([n, m]); end proc: PIE3({1, 5, 10, 15, 20, 25, 30}, {10, 20, 30}, {15, 30}, {1, 10, 30}); [2, 2] --------------------------------------------------------------------------------------------------------- V. PIE4 := proc(U, A1, A2, A3, A4) local n, m; if not type(U, set) then RETURN(FAIL); end if; if not type(A1, set) then RETURN(FAIL); end if; if not type(A2, set) then RETURN(FAIL); end if; if not type(A3, set) then RETURN(FAIL); end if; if not type(A4, set) then RETURN(FAIL); end if; if ((A1 intersect A2) intersect A3) intersect A4 = {} then RETURN(FAIL); end if; n := nops((((U minus A1) intersect (U minus A2)) intersect (U minus A3)) intersect (U minus A4)); m := nops(U) - (nops(A1) + nops(A2) + nops(A3) + nops(A4)) + (nops(A1 intersect A2) + nops(A1 intersect A3) + nops(A1 intersect A4) + nops(A2 intersect A3) + nops(A2 intersect A4) + nops(A3 intersect A4)) - (nops(A1 intersect A2 intersect A3) + nops(A2 intersect A3 intersect A4) + nops(A1 intersect A3 intersect A4) + nops(A1 intersect A2 intersect A4) + (nops(A1 intersect A2 intersect A3 intersect A4)); print([n, m]); end proc: PIE4({5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75}, {5, 10, 15, 20, 25, 35, 45, 60}, {15, 25, 30, 35, 40, 45, 50, 65}, {10, 20, 25, 35, 40, 50, 55, 70}, {5, 10, 15, 25, 30, 40, 55, 75}); [0, 0] ---------------------------------------------------------------------------------------------------------