Cody

Solution 1308642

Submitted on 22 Oct 2017
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

This solution is outdated. To rescore this solution, sign in.

Test Suite

Test Status Code Input and Output
1   Pass
x = '0'; y_correct = false; assert(isequal(tautology(x),y_correct))

2   Pass
x = '1'; y_correct = true; assert(isequal(tautology(x),y_correct))

3   Pass
x = 'A'; y_correct = false; assert(isequal(tautology(x),y_correct))

4   Fail
x = '~A'; y_correct = false; assert(isequal(tautology(x),y_correct))

Assertion failed.

5   Pass
x = 'A|1'; y_correct = true; assert(isequal(tautology(x),y_correct))

6   Pass
x = '1&A'; y_correct = false; assert(isequal(tautology(x),y_correct))

7   Pass
x = 'A|B'; y_correct = false; assert(isequal(tautology(x),y_correct))

8   Pass
x = 'A&B'; y_correct = false; assert(isequal(tautology(x),y_correct))

9   Pass
x = 'A|A'; y_correct = false; assert(isequal(tautology(x),y_correct))

10   Pass
x = 'A|~A'; y_correct = true; assert(isequal(tautology(x),y_correct))

11   Pass
x = '0==0'; y_correct = true; assert(isequal(tautology(x),y_correct))

12   Pass
x = '~0'; y_correct = true; assert(isequal(tautology(x),y_correct))

13   Fail
x = '~(A & B) == (~A | ~B)'; y_correct = true; assert(isequal(tautology(x),y_correct))

Assertion failed.

14   Fail
assert(isequal(tautology('(A|B)|C'),false));

NaN's cannot be converted to logicals. Error in tautology (line 16) y = str2double(x(1))|str2double(x(3)); Error in Test14 (line 1) assert(isequal(tautology('(A|B)|C'),false));

15   Fail
assert(isequal(tautology('(A|B)|(C == C)'),true));

Assertion failed.

16   Fail
assert(isequal(tautology('(A == B)|(B == C)|(C == A)'),true));

Assertion failed.

17   Fail
assert(isequal(tautology('~(~(~(~(~(~(0))))))'),false));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in Test17 (line 1) assert(isequal(tautology('~(~(~(~(~(~(0))))))'),false));

18   Fail
assert(isequal(tautology('~(~(~(~(~(~(~0))))))'),true)); % provided by Alfonso: assert(isequal(tautology('((0&1)|~B)&~B'),false));

Output argument "y" (and maybe others) not assigned during call to "tautology". Error in Test18 (line 1) assert(isequal(tautology('~(~(~(~(~(~(~0))))))'),true));

19   Fail
assert(isequal(tautology('((0&~B)&~B)'),false));

NaN's cannot be converted to logicals. Error in tautology (line 14) y = str2double(x(1))&str2double(x(3)); Error in Test19 (line 1) assert(isequal(tautology('((0&~B)&~B)'),false));

20   Fail
assert(isequal(tautology('((0|A)&~A)'),false));

NaN's cannot be converted to logicals. Error in tautology (line 14) y = str2double(x(1))&str2double(x(3)); Error in Test20 (line 1) assert(isequal(tautology('((0|A)&~A)'),false));

21   Fail
assert(isequal(tautology('((0|A)|1)'),true));

NaN's cannot be converted to logicals. Error in tautology (line 16) y = str2double(x(1))|str2double(x(3)); Error in Test21 (line 1) assert(isequal(tautology('((0|A)|1)'),true));

22   Fail
assert(isequal(tautology('((0|~B)|1)'),true));

NaN's cannot be converted to logicals. Error in tautology (line 16) y = str2double(x(1))|str2double(x(3)); Error in Test22 (line 1) assert(isequal(tautology('((0|~B)|1)'),true));

23   Fail
assert(isequal(tautology('((1&0)|B)'),false));

NaN's cannot be converted to logicals. Error in tautology (line 14) y = str2double(x(1))&str2double(x(3)); Error in Test23 (line 1) assert(isequal(tautology('((1&0)|B)'),false));

24   Fail
assert(isequal(tautology('((1&1)&A)'),false));

NaN's cannot be converted to logicals. Error in tautology (line 14) y = str2double(x(1))&str2double(x(3)); Error in Test24 (line 1) assert(isequal(tautology('((1&1)&A)'),false));

25   Fail
assert(isequal(tautology('((1|0)|A)'),true));

NaN's cannot be converted to logicals. Error in tautology (line 16) y = str2double(x(1))|str2double(x(3)); Error in Test25 (line 1) assert(isequal(tautology('((1|0)|A)'),true));

26   Fail
assert(isequal(tautology('((1|A)|0)'),true));

NaN's cannot be converted to logicals. Error in tautology (line 16) y = str2double(x(1))|str2double(x(3)); Error in Test26 (line 1) assert(isequal(tautology('((1|A)|0)'),true));

27   Fail
assert(isequal(tautology('((1|~A)&B)'),false));

NaN's cannot be converted to logicals. Error in tautology (line 14) y = str2double(x(1))&str2double(x(3)); Error in Test27 (line 1) assert(isequal(tautology('((1|~A)&B)'),false));

28   Fail
assert(isequal(tautology('((A&1)|~A)|A'),true));

NaN's cannot be converted to logicals. Error in tautology (line 14) y = str2double(x(1))&str2double(x(3)); Error in Test28 (line 1) assert(isequal(tautology('((A&1)|~A)|A'),true));

29   Fail
assert(isequal(tautology('((A&~A)&~B)|~A'),false));

NaN's cannot be converted to logicals. Error in tautology (line 14) y = str2double(x(1))&str2double(x(3)); Error in Test29 (line 1) assert(isequal(tautology('((A&~A)&~B)|~A'),false));

30   Fail
assert(isequal(tautology('((A&~B)&1)|B'),false));

NaN's cannot be converted to logicals. Error in tautology (line 14) y = str2double(x(1))&str2double(x(3)); Error in Test30 (line 1) assert(isequal(tautology('((A&~B)&1)|B'),false));

31   Fail
assert(isequal(tautology('((A|0)&1)&~B'),false));

NaN's cannot be converted to logicals. Error in tautology (line 14) y = str2double(x(1))&str2double(x(3)); Error in Test31 (line 1) assert(isequal(tautology('((A|0)&1)&~B'),false));

32   Fail
assert(isequal(tautology('((A|A)&A)|~A'),true));

NaN's cannot be converted to logicals. Error in tautology (line 14) y = str2double(x(1))&str2double(x(3)); Error in Test32 (line 1) assert(isequal(tautology('((A|A)&A)|~A'),true));

33   Fail
assert(isequal(tautology('((B|0)&B)'),false));

NaN's cannot be converted to logicals. Error in tautology (line 14) y = str2double(x(1))&str2double(x(3)); Error in Test33 (line 1) assert(isequal(tautology('((B|0)&B)'),false));

34   Fail
assert(isequal(tautology('((B|1)&B)&A'),false));

NaN's cannot be converted to logicals. Error in tautology (line 14) y = str2double(x(1))&str2double(x(3)); Error in Test34 (line 1) assert(isequal(tautology('((B|1)&B)&A'),false));

35   Fail
assert(isequal(tautology('((B|A)|~A)'),true));

NaN's cannot be converted to logicals. Error in tautology (line 16) y = str2double(x(1))|str2double(x(3)); Error in Test35 (line 1) assert(isequal(tautology('((B|A)|~A)'),true));

36   Fail
assert(isequal(tautology('((~A&~A)&0)&B'),false));

NaN's cannot be converted to logicals. Error in tautology (line 14) y = str2double(x(1))&str2double(x(3)); Error in Test36 (line 1) assert(isequal(tautology('((~A&~A)&0)&B'),false));

37   Fail
assert(isequal(tautology('((~A&~A)|0)'),false));

NaN's cannot be converted to logicals. Error in tautology (line 14) y = str2double(x(1))&str2double(x(3)); Error in Test37 (line 1) assert(isequal(tautology('((~A&~A)|0)'),false));

38   Fail
assert(isequal(tautology('((~A&~A)|~A)|1'),true));

NaN's cannot be converted to logicals. Error in tautology (line 14) y = str2double(x(1))&str2double(x(3)); Error in Test38 (line 1) assert(isequal(tautology('((~A&~A)|~A)|1'),true));

39   Fail
assert(isequal(tautology('((~A|A)|~B)&1'),true));

NaN's cannot be converted to logicals. Error in tautology (line 14) y = str2double(x(1))&str2double(x(3)); Error in Test39 (line 1) assert(isequal(tautology('((~A|A)|~B)&1'),true));

40   Fail
assert(isequal(tautology('((~A|B)|A)'),true));

NaN's cannot be converted to logicals. Error in tautology (line 16) y = str2double(x(1))|str2double(x(3)); Error in Test40 (line 1) assert(isequal(tautology('((~A|B)|A)'),true));

41   Fail
assert(isequal(tautology('((~A|~A)|1)'),true));

NaN's cannot be converted to logicals. Error in tautology (line 16) y = str2double(x(1))|str2double(x(3)); Error in Test41 (line 1) assert(isequal(tautology('((~A|~A)|1)'),true));

42   Fail
assert(isequal(tautology('((~A|~B)&0)'),false));

NaN's cannot be converted to logicals. Error in tautology (line 14) y = str2double(x(1))&str2double(x(3)); Error in Test42 (line 1) assert(isequal(tautology('((~A|~B)&0)'),false));

43   Fail
assert(isequal(tautology('((~B&0)&A)'),false));

NaN's cannot be converted to logicals. Error in tautology (line 14) y = str2double(x(1))&str2double(x(3)); Error in Test43 (line 1) assert(isequal(tautology('((~B&0)&A)'),false));

44   Fail
assert(isequal(tautology('(0&1)|1&1'),true));

NaN's cannot be converted to logicals. Error in tautology (line 14) y = str2double(x(1))&str2double(x(3)); Error in Test44 (line 1) assert(isequal(tautology('(0&1)|1&1'),true));

45   Fail
assert(isequal(tautology('(0|~A&B)'),false));

NaN's cannot be converted to logicals. Error in tautology (line 14) y = str2double(x(1))&str2double(x(3)); Error in Test45 (line 1) assert(isequal(tautology('(0|~A&B)'),false));

46   Fail
assert(isequal(tautology('(1|A&0)'),true));

NaN's cannot be converted to logicals. Error in tautology (line 14) y = str2double(x(1))&str2double(x(3)); Error in Test46 (line 1) assert(isequal(tautology('(1|A&0)'),true));

47   Fail
assert(isequal(tautology('(A&A&~B)'),false));

NaN's cannot be converted to logicals. Error in tautology (line 14) y = str2double(x(1))&str2double(x(3)); Error in Test47 (line 1) assert(isequal(tautology('(A&A&~B)'),false));

48   Fail
assert(isequal(tautology('(A&~A|1)'),true));

NaN's cannot be converted to logicals. Error in tautology (line 14) y = str2double(x(1))&str2double(x(3)); Error in Test48 (line 1) assert(isequal(tautology('(A&~A|1)'),true));

49   Fail
assert(isequal(tautology('(A|1)|B'),true));

NaN's cannot be converted to logicals. Error in tautology (line 16) y = str2double(x(1))|str2double(x(3)); Error in Test49 (line 1) assert(isequal(tautology('(A|1)|B'),true));

50   Fail
assert(isequal(tautology('(A|A)|A|1'),true));

NaN's cannot be converted to logicals. Error in tautology (line 16) y = str2double(x(1))|str2double(x(3)); Error in Test50 (line 1) assert(isequal(tautology('(A|A)|A|1'),true));

51   Fail
assert(isequal(tautology('(B&1)|~B'),true));

NaN's cannot be converted to logicals. Error in tautology (line 14) y = str2double(x(1))&str2double(x(3)); Error in Test51 (line 1) assert(isequal(tautology('(B&1)|~B'),true));

52   Fail
assert(isequal(tautology('(B&~B)&~B&0'),false));

NaN's cannot be converted to logicals. Error in tautology (line 14) y = str2double(x(1))&str2double(x(3)); Error in Test52 (line 1) assert(isequal(tautology('(B&~B)&~B&0'),false));

53   Fail
assert(isequal(tautology('(B|~B)|B'),true));

NaN's cannot be converted to logicals. Error in tautology (line 16) y = str2double(x(1))|str2double(x(3)); Error in Test53 (line 1) assert(isequal(tautology('(B|~B)|B'),true));

54   Fail
assert(isequal(tautology('(~A&B&0)'),false));

NaN's cannot be converted to logicals. Error in tautology (line 14) y = str2double(x(1))&str2double(x(3)); Error in Test54 (line 1) assert(isequal(tautology('(~A&B&0)'),false));

55   Fail
assert(isequal(tautology('(~A|0)|~B&~A'),false));

NaN's cannot be converted to logicals. Error in tautology (line 14) y = str2double(x(1))&str2double(x(3)); Error in Test55 (line 1) assert(isequal(tautology('(~A|0)|~B&~A'),false));

56   Fail
assert(isequal(tautology('(~A|1)|1'),true));

NaN's cannot be converted to logicals. Error in tautology (line 16) y = str2double(x(1))|str2double(x(3)); Error in Test56 (line 1) assert(isequal(tautology('(~A|1)|1'),true));

57   Fail
assert(isequal(tautology('(~A|B&B)'),false));

NaN's cannot be converted to logicals. Error in tautology (line 14) y = str2double(x(1))&str2double(x(3)); Error in Test57 (line 1) assert(isequal(tautology('(~A|B&B)'),false));

58   Fail
assert(isequal(tautology('(~A|B)|~B'),true));

NaN's cannot be converted to logicals. Error in tautology (line 16) y = str2double(x(1))|str2double(x(3)); Error in Test58 (line 1) assert(isequal(tautology('(~A|B)|~B'),true));

59   Fail
assert(isequal(tautology('(~A|~A)|0'),false));

NaN's cannot be converted to logicals. Error in tautology (line 16) y = str2double(x(1))|str2double(x(3)); Error in Test59 (line 1) assert(isequal(tautology('(~A|~A)|0'),false));

60   Fail
assert(isequal(tautology('(~B&0)&1|1'),true));

NaN's cannot be converted to logicals. Error in tautology (line 14) y = str2double(x(1))&str2double(x(3)); Error in Test60 (line 1) assert(isequal(tautology('(~B&0)&1|1'),true));

61   Fail
assert(isequal(tautology('1&B|~B|0'),true));

Assertion failed.

62   Pass
assert(isequal(tautology('B&1&A&1'),false));

63   Fail
assert(isequal(tautology('~A&0&1|1'),true));

Assertion failed.

64   Pass
assert(isequal(tautology('~B&0&~A|B'),false));

65   Pass
assert(isequal(tautology('~B|1|1|~B'),true));

66   Pass
assert(isequal(tautology('~B|~B&1|1'),true));