Cody

Problem 44377. Five steps to enlightenment

Solution 3135791

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

Test Suite

Test Status Code Input and Output
1   Pass
assessFunctionAbsence({'regexp','regexpi','regexprep','str2num'},'FileName','fivesteps.m') assert(isempty(regexp(fileread('fivesteps.m'),'assert'))); [~,~]=system('rm freepass*');

2   Pass
%lines=textread('fivesteps.m','%s'); %id=str2num(regexp(lines{end},'\d+','match','once')); %assert(~ismember(id,[3430216]),'Please submit a valid non-cheating solution and ask the problem author to manually evaluate it'); % [3931805,3397427,3430216]

3   Fail
% X,Y X<Y between 2 and 100 [x,y]=find(triu(ones(100),1)); z=[x y]; valid=all(z>1,2); assert(fivesteps(z(valid,:))==true);

ans = 4851 2 ans = 3097 2 ans = 22 2 ans = 3 4 3 4 5 4 2 6 2 3 6 3 4 6 4 4 8 4 2 10 2 80 85 80 84 88 84 88 90 88 84 91 84 80 95 80 69 96 69 77 96 77 78 98 78 72 99 72 80 99 80 68 100 68 76 100 76

Output argument "valid" (and maybe others) not assigned during call to "fivesteps". Error in Test3 (line 5) assert(fivesteps(z(valid,:))==true);

4   Fail
% X,Y X<Y between 2 and 60 [x,y]=find(triu(ones(60),1)); z=[x y]; valid=all(z>1,2); assert(fivesteps(z(valid,:))==false);

ans = 1711 2 ans = 1026 2 ans = 18 2 ans = 3 4 3 4 5 4 2 6 2 3 6 3 4 6 4 4 8 4 2 10 2 42 48 42 50 54 50 48 55 48 45 56 45 30 60 30 36 60 36 39 60 39 40 60 40 42 60 42 44 60 44 45 60 45

Output argument "valid" (and maybe others) not assigned during call to "fivesteps". Error in Test4 (line 5) assert(fivesteps(z(valid,:))==false);

5   Fail
% X,Y X<Y between 2 and 200 [x,y]=find(triu(ones(200),1)); z=[x y]; valid=all(z>1,2); assert(fivesteps(z(valid,:))==true);

ans = 19701 2 ans = 12808 2 ans = 29 2 ans = 3 4 3 4 5 4 2 6 2 3 6 3 4 6 4 4 8 4 2 10 2 180 182 180 175 184 175 180 187 180 168 189 168 176 189 176 180 190 180 150 192 150 175 192 175 160 195 160 168 195 168 162 196 162 144 198 144 168 198 168 170 198 170 154 200 154 156 200 156 161 200 161 168 200 168 171 200 171

Output argument "valid" (and maybe others) not assigned during call to "fivesteps". Error in Test5 (line 5) assert(fivesteps(z(valid,:))==true);

6   Fail
% X,Y X<Y between 2 and 1680 [x,y]=find(triu(ones(1680),1)); z=[x y]; valid=all(z>1,2); assert(fivesteps(z(valid,:))==true);

ans = 1408681 2 ans = 1012440 2 ans = 75 2 ans = 3 4 3 4 5 4 2 6 2 3 6 3 4 6 4 4 8 4 2 10 2 1591 1599 1591 1598 1617 1598 1586 1620 1586 1595 1620 1595 1610 1620 1610 1612 1620 1612 1596 1628 1596 1620 1628 1620 1560 1632 1560 1575 1632 1575 1610 1632 1610 1617 1632 1617 1606 1633 1606 1628 1634 1628 1530 1638 1530 1560 1638 1560 1591 1638 1591 1634 1638 1634 1596 1640 1596 1638 1640 1638 1584 1645 1584 1632 1645 1632 1560 1647 1560 1575 1648 1575 1554 1650 1554 1560 1650 1560 1596 1650 1596 1608 1650 1608 1624 1650 1624 1620 1652 1620 1584 1653 1584 1581 1656 1581 1606 1656 1606 1610 1656 1610 1596 1660 1596 1575 1664 1575 1581 1664 1581 1548 1665 1548 1584 1665 1584 1560 1666 1560 1584 1666 1584 1554 1672 1554 1575 1672 1575 1530 1674 1530 1560 1674 1560 1586 1674 1586 1590 1674 1590 1560 1675 1560 1536 1677 1536 1558 1677 1558 1596 1677 1596 1562 1679 1562 1512 1680 1512 1518 1680 1518 1526 1680 1526 1530 1680 1530 1545 1680 1545 1547 1680 1547 1554 1680 1554 1560 1680 1560 1566 1680 1566 1577 1680 1577 1580 1680 1580 1587 1680 1587 1593 1680 1593 1595 1680 1595 1598 1680 1598 1599 1680 1599

Output argument "valid" (and maybe others) not assigned during call to "fivesteps". Error in Test6 (line 5) assert(fivesteps(z(valid,:))==true);

7   Fail
% X,Y X<Y between 2 and 1700 [x,y]=find(triu(ones(1700),1)); z=[x y]; valid=all(z>1,2); assert(fivesteps(z(valid,:))==false);

ans = 1442451 2 ans = 1035877 2 ans = 69 2 ans = 3 4 3 4 5 4 2 6 2 3 6 3 4 6 4 4 8 4 2 10 2 1610 1620 1610 1540 1628 1540 1617 1628 1617 1560 1632 1560 1610 1632 1610 1530 1638 1530 1591 1638 1591 1615 1640 1615 1600 1643 1600 1584 1645 1584 1620 1645 1620 1608 1650 1608 1624 1650 1624 1573 1652 1573 1602 1653 1602 1610 1656 1610 1645 1656 1645 1581 1664 1581 1625 1664 1625 1643 1664 1643 1548 1665 1548 1582 1665 1582 1584 1666 1584 1600 1666 1600 1650 1666 1650 1575 1672 1575 1602 1672 1602 1617 1672 1617 1560 1674 1560 1590 1674 1590 1632 1675 1632 1536 1677 1536 1512 1680 1512 1545 1680 1545 1547 1680 1547 1554 1680 1554 1560 1680 1560 1573 1680 1573 1590 1680 1590 1599 1680 1599 1615 1680 1615 1568 1683 1568 1550 1690 1550 1575 1690 1575 1600 1690 1600 1610 1692 1610 1533 1694 1533 1534 1694 1534 1575 1694 1575 1596 1694 1596 1575 1696 1575 1612 1696 1612 1551 1700 1551 1552 1700 1552 1558 1700 1558 1568 1700 1568 1596 1700 1596 1608 1700 1608 1617 1700 1617

Output argument "valid" (and maybe others) not assigned during call to "fivesteps". Error in Test7 (line 5) assert(fivesteps(z(valid,:))==false);

8   Fail
% X,Y X<Y between 1 and 20 [x,y]=find(triu(ones(20),1)); z=[x y]; valid=all(z>=1,2); assert(fivesteps(z(valid,:))==false);

ans = 190 2 ans = 87 2 ans = 17 2 ans = 2 3 2 2 4 2 3 5 3 2 6 2 4 6 4 2 8 2 4 8 4 2 10 2 9 16 9 15 16 15 7 18 7 7 20 7 8 20 8 12 20 12

Output argument "valid" (and maybe others) not assigned during call to "fivesteps". Error in Test8 (line 5) assert(fivesteps(z(valid,:))==false);

9   Fail
% X,Y X<Y between 1 and 30 [x,y]=find(triu(ones(30),1)); z=[x y]; valid=all(z>=1,2); assert(fivesteps(z(valid,:))==true);

ans = 435 2 ans = 239 2 ans = 16 2 ans = 2 3 2 2 4 2 3 5 3 2 6 2 18 24 18 20 24 20 21 24 21 24 25 24 20 27 20 18 28 18 12 30 12 14 30 14 15 30 15 16 30 16 18 30 18 20 30 20

Output argument "valid" (and maybe others) not assigned during call to "fivesteps". Error in Test9 (line 5) assert(fivesteps(z(valid,:))==true);

10   Fail
% X,Y X<Y between 1 and 40 [x,y]=find(triu(ones(40),1)); z=[x y]; valid=all(z>=1,2); assert(fivesteps(z(valid,:))==false);

ans = 780 2 ans = 474 2 ans = 16 2 ans = 2 3 2 2 4 2 3 5 3 2 6 2 30 32 30 32 35 32 24 36 24 26 36 26 30 36 30 22 39 22 24 39 24 20 40 20 21 40 21 24 40 24 27 40 27 28 40 28

Output argument "valid" (and maybe others) not assigned during call to "fivesteps". Error in Test10 (line 5) assert(fivesteps(z(valid,:))==false);

11   Fail
% X,Y X<Y between 3 and 5000 [x,y]=find(triu(ones(3000),1)); z=[x y]; valid=all(z>=3,2); assert(fivesteps(z(valid,:))==true);

ans = 4492503 2 ans = 3278128 2 ans = 84 2 ans = 4 6 4 5 6 5 3 8 3 2880 2886 2880 2886 2889 2886 2870 2898 2870 2880 2898 2880 2890 2904 2890 2900 2910 2900 2898 2911 2898 2907 2912 2907 2880 2914 2880 2905 2916 2905 2916 2923 2916 2898 2924 2898 2920 2925 2920 2891 2928 2891 2880 2937 2880 2850 2938 2850 2832 2940 2832 2871 2940 2871 2900 2940 2900 2911 2940 2911 2928 2940 2928 2925 2944 2925 2880 2945 2880 2924 2948 2924 2940 2950 2940 2847 2952 2847 2920 2952 2920 2838 2958 2838 2850 2958 2850 2904 2958 2904 2808 2960 2808 2850 2960 2850 2916 2960 2916 2925 2960 2925 2825 2964 2825 2850 2964 2850 2856 2964 2856 2875 2964 2875 2808 2970 2808 2848 2970 2848 2856 2970 2856 2862 2970 2862 2886 2970 2886 2900 2970 2900 2880 2975 2880 2790 2976 2790 2820 2976 2820 2850 2976 2850 2867 2976 2867 2875 2976 2875 2829 2982 2829 2870 2982 2870 2828 2987 2828 2856 2987 2856 2800 2988 2800 2870 2988 2870 2820 2989 2820 2832 2989 2832 2880 2989 2880 2825 2990 2825 2835 2990 2835 2850 2990 2850 2880 2990 2880 2752 2992 2752 2871 2992 2871 2881 2992 2881 2840 2993 2840 2880 2993 2880 2862 2996 2862 2844 2997 2844 2880 2997 2880 2744 3000 2744 2772 3000 2772 2808 3000 2808 2832 3000 2832 2847 3000 2847 2852 3000 2852 2856 3000 2856 2871 3000 2871 2886 3000 2886 2891 3000 2891

Output argument "valid" (and maybe others) not assigned during call to "fivesteps". Error in Test11 (line 5) assert(fivesteps(z(valid,:))==true);

12   Fail
% X,Y X<Y between 3 and 100 [x,y]=find(triu(ones(100),1)); z=[x y]; valid=all(z>=3,2); assert(fivesteps(z(valid,:))==false);

ans = 4753 2 ans = 3006 2 ans = 18 2 ans = 4 6 4 5 6 5 3 8 3 80 85 80 84 88 84 88 90 88 84 91 84 80 95 80 69 96 69 77 96 77 78 98 78 72 99 72 80 99 80 68 100 68 76 100 76

Output argument "valid" (and maybe others) not assigned during call to "fivesteps". Error in Test12 (line 5) assert(fivesteps(z(valid,:))==false);

13   Fail
% X,Y X<Y even between 2 and 40 [x,y]=meshgrid(2:2:40); z=[x(:) y(:)]; valid=y>x; assert(fivesteps(z(valid,:))==false);

ans = 190 2 ans = 87 2 ans = 17 2 ans = 4 6 4 4 8 4 4 12 4 4 16 4 4 20 4 6 10 6 8 12 8 8 16 8 14 36 14 14 40 14 16 40 16 18 32 18 24 40 24 30 32 30

Output argument "valid" (and maybe others) not assigned during call to "fivesteps". Error in Test13 (line 5) assert(fivesteps(z(valid,:))==false);

14   Fail
% X,Y X<Y odd between 1 and 1000 [x,y]=meshgrid(1:2:1000); z=[x(:) y(:)]; valid=y>x; assert(fivesteps(z(valid,:))==true);

ans = 124750 2 ans = 53829 2 ans = 60 2 ans = 3 5 3 3 7 3 3 9 3 3 11 3 5 7 5 5 9 5 707 999 707 721 981 721 731 987 731 735 963 735 735 975 735 741 987 741 749 945 749 749 999 749 765 987 765 767 975 767 775 957 775 775 999 775 777 963 777 777 975 777 781 975 781 783 935 783 783 957 783 793 945 793 795 969 795 799 903 799 801 913 801 801 935 801 803 975 803 805 975 805 805 999 805 817 897 817 817 987 817 819 875 819 819 989 819 825 923 825 825 945 825 825 949 825 825 999 825 833 969 833 837 899 837 841 891 841 851 891 851 851 903 851 851 945 851 851 975 851 855 901 855 855 987 855 861 893 861 861 989 861 867 931 867 875 897 875 875 999 875 891 925 891 893 903 893 893 945 893 897 903 897 897 925 897 903 943 903 925 945 925

Output argument "valid" (and maybe others) not assigned during call to "fivesteps". Error in Test14 (line 5) assert(fivesteps(z(valid,:))==true);

15   Fail
% X,Y X<Y non-primes between 1 and 50 [x,y]=meshgrid(setdiff(1:50,primes(50))); z=[x(:) y(:)]; valid=y>x; assert(fivesteps(z(valid,:))==true);

ans = 595 2 ans = 354 2 ans = 30 2 ans = 4 6 4 4 9 4 4 10 4 4 12 4 4 15 4 6 8 6 6 10 6 6 12 6 6 14 6 6 15 6 8 9 8 8 10 8 8 12 8 8 15 8 9 10 9 9 12 9 9 14 9 28 48 28 28 50 28 30 45 30 30 48 30 30 49 30 33 48 33 35 40 35 35 48 35 36 40 36 36 44 36 36 50 36 40 42 40 40 45 40

Output argument "valid" (and maybe others) not assigned during call to "fivesteps". Error in Test15 (line 5) assert(fivesteps(z(valid,:))==true);

16   Fail
% X,Y X<Y primes between 1 and 50 [x,y]=meshgrid(primes(50)); z=[x(:) y(:)]; valid=y>x; assert(fivesteps(z(valid,:))==false);

ans = 105 2 ans = 0 2 ans = 0 2 ans = 0×3 empty double matrix

Output argument "valid" (and maybe others) not assigned during call to "fivesteps". Error in Test16 (line 5) assert(fivesteps(z(valid,:))==false);

17   Fail
% X,Y X<Y between 3 and 100 [x,y]=find(triu(ones(randi([10,100])),1)); z=[x y]; valid=all(z>2,2); assert(fivesteps(z(valid,:))==false);

ans = 2775 2 ans = 1666 2 ans = 16 2 ans = 4 6 4 5 6 5 3 8 3 60 66 60 63 66 63 54 70 54 60 70 60 66 70 66 48 72 48 56 72 56 57 72 57 56 75 56 48 76 48 54 76 54 54 77 54 60 77 60

Output argument "valid" (and maybe others) not assigned during call to "fivesteps". Error in Test17 (line 5) assert(fivesteps(z(valid,:))==false);

18   Fail
% X,Y X<Y between 1 and 100 [x,y]=find(triu(ones(randi([40,100])),1)); z=[x y]; valid=all(z>=1,2); assert(fivesteps(z(valid,:))==false);

ans = 1176 2 ans = 683 2 ans = 16 2 ans = 2 3 2 2 4 2 3 5 3 2 6 2 30 42 30 35 42 35 40 42 40 36 44 36 24 48 24 28 48 28 33 48 33 35 48 35 30 49 30

Output argument "valid" (and maybe others) not assigned during call to "fivesteps". Error in Test18 (line 5) assert(fivesteps(z(valid,:))==false);

19   Fail
% X,Y X<Y between 2 and 100 [x,y]=find(triu(ones(randi([62,100])),1)); z=[x y]; valid=all(z>1,2); assert(fivesteps(z(valid,:))==true);

ans = 3570 2 ans = 2203 2 ans = 20 2 ans = 3 4 3 4 5 4 2 6 2 3 6 3 4 6 4 4 8 4 2 10 2 63 72 63 68 75 68 70 78 70 60 80 60 68 80 68 51 84 51 57 84 57 66 84 66 56 85 56 60 85 60

Output argument "valid" (and maybe others) not assigned during call to "fivesteps". Error in Test19 (line 5) assert(fivesteps(z(valid,:))==true);

20   Fail
% X,Y X<Y between 2 and 100 [x,y]=find(triu(ones(randi([10,61])),1)); z=[x y]; valid=all(z>1,2); assert(fivesteps(z(valid,:))==false);

ans = 1081 2 ans = 614 2 ans = 17 2 ans = 3 4 3 4 5 4 2 6 2 3 6 3 4 6 4 4 8 4 2 10 2 30 42 30 40 42 40 36 44 36 24 48 24 28 48 28 33 48 33 35 48 35

Output argument "valid" (and maybe others) not assigned during call to "fivesteps". Error in Test20 (line 5) assert(fivesteps(z(valid,:))==false);

21   Fail
% X,Y X<Y in 3 5 12 18 20 28 30 % Possible solutions after step 1: [3,20] [3,30] [5,18] [5,28] [18,30] [20,28] % Possible solutions after step 2: [3,30] [5,18] % Possible solutions after step 3: [5,18] % Possible solutions after step 4: [5,18] % Possible solutions after step 5: [5,18] [x,y]=meshgrid([3 5 12 18 20 28 30]); z=[x(:) y(:)]; valid=y>x; assert(fivesteps(z(valid,:))==true);

ans = 21 2 ans = 2 2 ans = 2 2 ans = 3 30 3 5 18 5

Output argument "valid" (and maybe others) not assigned during call to "fivesteps". Error in Test21 (line 10) assert(fivesteps(z(valid,:))==true);

22   Fail
% X,Y X<Y in 3 5 12 15 28 30 % Possible solutions after step 1: [3,30] [5,28] % Possible solutions after step 2: [x,y]=meshgrid([3 5 12 15 28 30]); z=[x(:) y(:)]; valid=y>x; assert(fivesteps(z(valid,:))==false);

ans = 15 2 ans = 0 2 ans = 0 2 ans = 0×3 empty double matrix

Output argument "valid" (and maybe others) not assigned during call to "fivesteps". Error in Test22 (line 7) assert(fivesteps(z(valid,:))==false);

23   Fail
% X,Y X<Y in 2 4 6 8 12 16 18 % Possible solutions after step 1: [2,8] [2,12] [2,16] [2,18] [4,6] [4,16] [4,18] [6,8] [6,12] [6,16] [6,18] [8,12] [8,16] % Possible solutions after step 2: [2,12] [4,6] [4,18] [6,12] [6,16] [8,12] % Possible solutions after step 3: [2,12] [4,18] [6,12] [6,16] % Possible solutions after step 4: [2,12] [6,16] % Possible solutions after step 5: [2,12] [6,16] [x,y]=meshgrid([2 4 6 8 12 16 18]); z=[x(:) y(:)]; valid=y>x; assert(fivesteps(z(valid,:))==false);

ans = 21 2 ans = 6 2 ans = 6 2 ans = 2 12 2 4 6 4 4 18 4 6 12 6 6 16 6 8 12 8

Output argument "valid" (and maybe others) not assigned during call to "fivesteps". Error in Test23 (line 10) assert(fivesteps(z(valid,:))==false);

24   Fail
% X,Y X<Y in 4 6 8 12 16 18 % Possible solutions after step 1: [4,16] [4,18] [6,16] [6,18] [8,12] [8,16] % Possible solutions after step 2: [6,16] [8,12] % Possible solutions after step 3: [6,16] % Possible solutions after step 4: [6,16] % Possible solutions after step 5: [6,16] [x,y]=meshgrid([4 6 8 12 16 18]); z=[x(:) y(:)]; valid=y>x; assert(fivesteps(z(valid,:))==true);

ans = 15 2 ans = 2 2 ans = 2 2 ans = 6 16 6 8 12 8

Output argument "valid" (and maybe others) not assigned during call to "fivesteps". Error in Test24 (line 10) assert(fivesteps(z(valid,:))==true);

25   Fail
% X,Y X<Y in 2 3 10 14 15 20 21 % Possible solutions after step 1: [2,15] [2,21] [3,14] [3,20] [3,21] [10,14] [14,21] [15,20] % Possible solutions after step 2: [2,21] [3,14] % Possible solutions after step 3: [3,14] % Possible solutions after step 4: [3,14] % Possible solutions after step 5: [3,14] [x,y]=meshgrid([2 3 10 14 15 20 21]); z=[x(:) y(:)]; valid=y>x; assert(fivesteps(z(valid,:))==true);

ans = 21 2 ans = 2 2 ans = 2 2 ans = 2 21 2 3 14 3

Output argument "valid" (and maybe others) not assigned during call to "fivesteps". Error in Test25 (line 10) assert(fivesteps(z(valid,:))==true);

26   Fail
% X,Y X<Y in 2 3 5 8 10 14 15 20 21 % Possible solutions after step 1: [2,15] [2,20] [2,21] [3,10] [3,14] [3,15] [3,20] [3,21] [5,8] [5,20] [8,10] [8,14] [8,15] [8,21] [10,14] [10,15] [14,15] [14,21] [15,20] % Possible solutions after step 2: [2,15] [2,20] [2,21] [3,10] [3,14] [5,8] % Possible solutions after step 3: [2,15] [3,10] [3,14] [5,8] % Possible solutions after step 4: [3,14] [5,8] % Possible solutions after step 5: [3,14] [5,8] [x,y]=meshgrid([2 3 5 8 10 14 15 20 21]); z=[x(:) y(:)]; valid=y>x; assert(fivesteps(z(valid,:))==false);

ans = 36 2 ans = 6 2 ans = 6 2 ans = 2 15 2 2 20 2 2 21 2 3 10 3 3 14 3 5 8 5

Output argument "valid" (and maybe others) not assigned during call to "fivesteps". Error in Test26 (line 10) assert(fivesteps(z(valid,:))==false);

27   Fail
% a few random cases to discourage look-up table solutions data={[2 5 6 7 9 10 12 16 23 25 26 27 28 29 31],[49 94 97 109 112 113 154 157 158 161 184 187 188 191 193 199 202 203 206 208 209 214 217 218 221 223 224 225];... [2 4 6 9 10 11 12 13 14 20 22 23 25 26 28],[49 64 79 81 109 111 113 124 125 126 128 129 154 156 158 159 161 169 171 173 174 176 177 184 186 188 189 191 192 193 199 201 203 204 206 207 208 209 214 216 218 219 221 222 223 224 225];... [2 3 4 6 7 9 10 11 12 14 19 20 21 24 25 28 31],[19 35 87 89 108 109 121 124 126 127 142 144 145 155 156 171 174 175 177 180 206 215 223 230 240 241 245 247 253 257 262 263 264 270 271 274 278 279 280 281 285 288 289];... [2 4 5 6 8 9 10 11 15 16 18 19 20 21 23 24 25 26 27 28 29],[45 66 67 87 109 111 150 152 153 171 174 177 214 219 221 234 235 237 240 242 243 256 258 261 263 264 265 276 277 279 282 284 285 286 287 297 298 300 303 305 306 307 308 309 319 321 324 326 327 328 329 330 331 339 340 342 345 347 348 349 350 351 352 353 360 361 363 366 368 369 370 371 372 373 374 375 381 382 384 387 389 390 391 392 393 394 395 396 397 402 403 405 408 410 411 412 413 414 415 416 417 418 419 423 424 426 429 431 432 433 434 435 436 437 438 439 440 441];... [2 4 5 6 8 10 11 12 14 16 17 25 27 28 29 30 31],[1 54 89 109 125 137 140 144 145 154 156 171 177 179 181 188 194 196 198 199 205 208 211 213 216 217 222 225 228 229 230 232 233 234 235 239 245 247 248 250 251 252 253 256 262 264 266 267 268 269 270 271 273 279 281 283 284 285 286 287 288 289];... [2 5 6 7 10 14 15 16 17 20 21 23 24 25 29 30],[120 152 154 168 170 171 184 185 186 187 188 200 202 203 204 205 216 218 219 220 221 222 232 234 235 236 237 238 239 248 250 251 252 253 254 255 256];... [4 5 7 8 9 11 12 15 16 17 20 21 24 27 28 30],[18 68 82 85 86 98 100 102 103 116 118 119 120 129 130 136 146 150 151 152 153 162 166 168 169 171 194 196 198 199 202 203 205 212 226 230 231 232 233 235 237 239 244 249 250];... [2 3 4 6 8 9 11 12 13 15 17 19 20 21 22 23 25 28 29 31],[22 43 102 122 123 127 147 148 162 163 168 169 182 187 188 190 202 203 207 208 209 210 211 222 223 227 228 229 230 231 232 242 243 247 248 249 250 251 252 253 262 263 267 268 269 270 271 272 273 274 282 283 287 288 289 290 291 292 293 294 295 302 303 307 308 309 310 311 312 313 314 315 316 322 323 327 328 329 330 331 332 333 334 335 336 337 342 343 347 348 349 350 351 352 353 354 355 356 357 358 362 363 367 368 369 370 371 372 373 374 375 376 377 378 379 382 383 387 388 389 390 391 392 393 394 395 396 397 398 399 400];... [3 4 5 6 8 9 10 11 13 14 18 19 21 22 23 25 26 28 29 30 31],[111 150 153 154 155 174 176 177 195 197 198 199 216 218 219 220 221 237 239 240 242 243 258 260 261 262 263 264 265 279 281 282 283 284 285 286 287 300 302 303 304 305 306 307 308 309 321 323 324 325 326 327 328 329 330 331 342 344 345 346 347 348 349 350 351 352 353 363 365 366 367 368 369 370 371 372 373 374 375 384 386 387 388 389 390 391 392 393 394 395 396 397 405 407 408 409 410 411 412 413 414 415 416 417 418 419 426 428 429 430 431 432 433 434 435 436 437 438 439 440 441];... [2 4 5 6 8 10 11 13 14 15 16 17 20 22 28 31],[51 52 83 100 103 132 135 136 137 148 151 153 154 168 183 185 187 188 196 199 200 201 202 204 205 212 215 217 218 220 221 222 228 231 232 233 234 236 237 238 239 244 247 249 250 252 253 254 255 256];... [2 4 5 8 10 11 12 15 20 21 22 26 28 29 30 31],[1 65 82 103 119 120 129 145 151 152 154 177 183 184 186 188 193 199 200 204 205 209 215 216 218 220 221 222 225 231 232 234 236 237 238 239 241 247 248 250 252 253 254 255 256];... [2 4 5 7 8 12 13 17 18 19 22 26 28 29 30],[49 64 65 109 110 113 124 125 128 129 139 140 143 144 145 154 155 158 159 160 161 184 185 188 189 191 193 199 200 203 204 205 206 208 209];... [2 3 6 8 9 12 15 17 18 19 21 22 23 24 25 27 28 29 30],[81 96 119 121 137 138 140 141 157 159 160 161 176 180 195 197 198 199 201 214 216 217 218 220 221 233 235 237 239 240 241 254 255 256 258 259 260 261 271 273 274 275 277 278 279 280 281 290 292 293 294 296 297 298 299 300 301 309 311 312 313 315 316 317 318 319 320 321 328 330 331 332 334 335 336 337 338 339 340 341 347 349 350 351 352 353 354 355 356 357 358 359 360 361];... [6 7 9 11 17 18 21 22 23 27 28 29],[53 101 105 125 129 131 137 141 143 144];... [2 3 4 6 8 9 11 12 15 16 18 19 20 22 24 25 27 28 29 30],[22 81 83 102 103 121 122 127 147 148 161 164 166 167 168 188 189 190 202 203 208 210 211 222 231 232 242 247 248 250 251 252 253 262 263 267 268 269 270 271 272 273 274 285 287 288 290 291 292 293 294 295 310 314 315 316 322 323 327 328 330 331 332 333 334 335 336 337 347 348 350 351 352 353 354 355 356 357 358 362 367 368 370 371 372 373 374 375 376 377 378 379 382 387 388 390 391 392 393 394 395 396 397 398 399 400];... [3 4 5 6 10 11 13 17 20 21 25 26 30],[57 70 71 96 97 99 161 162 164 169];... [2 3 4 10 12 15 16 18 19 20 21 22 25 26 28 30 31],[1 52 55 120 123 127 140 144 145 157 161 162 163 171 174 178 179 180 181 188 191 195 196 197 198 199 205 208 212 213 214 215 216 217 222 225 229 230 231 232 233 234 235 239 242 246 247 248 249 250 251 252 253 256 259 263 264 266 267 268 269 270 271 273 276 280 281 282 283 284 285 286 287 288 289];... [2 4 5 7 10 15 16 18 20 24 25 27 28 29 30 31],[17 18 82 86 98 102 103 114 118 119 120 146 150 151 152 154 178 182 183 186 187 188 209 210 214 215 216 218 220 222 226 230 231 232 234 236 238 239 242 246 247 248 250 252 254 255 256];... [4 6 7 10 11 12 18 20 21 22 24 28],[26 27 40 51 52 88 97 99 101 103 105 112 113 117 123 124 131 133 134 136 139 141 143];... [2 3 4 6 8 10 12 14 15 17 18 19 20 21 22 24 26 28 30],[20 41 79 80 117 118 119 121 137 138 141 156 157 160 174 178 181 193 197 198 200 201 212 213 214 220 221 229 231 232 233 235 238 239 240 241 251 252 255 269 272 274 276 277 279 281 288 292 293 295 296 297 298 300 301 307 311 312 314 315 316 317 319 320 321 326 330 331 333 334 335 336 338 339 340 341 345 349 350 352 353 354 355 357 358 359 360 361];... [2 3 4 6 8 10 12 13 15 16 18 19 20 22 25 26 29],[18 35 37 70 72 88 91 105 106 107 121 124 139 140 141 144 145 160 161 163 173 176 179 180 181 190 195 197 207 208 209 211 214 215 216 217 224 227 230 231 232 234 235 241 247 248 249 251 252 253 258 259 260 275 278 281 282 283 285 286 287 289];... [3 4 5 8 9 12 14 21 23 24 28 30],[1 49 53 97 101 105 121 125 129 131];... [2 3 6 7 8 9 12 13 15 16 18 19 22 23 24 26 28],[52 55 89 103 120 124 140 145 157 159 174 179 181 191 196 198 199 208 213 215 216 217 230 232 235 242 245 247 249 250 251 252 253 259 261 276 278];... [2 4 6 8 9 10 11 12 21 22 24 25 26 27 28 29 31],[1 19 37 55 73 86 87 89 90 104 121 123 124 125 127 137 139 140 141 144 145 155 159 172 174 178 179 181 188 189 190 192 194 195 198 199 205 206 207 208 212 215 216 217 222 224 226 227 239 241 242 243 246 247 249 250 251 253 256 257 258 259 260 263 264 266 267 268 270 271 273 274 275 276 277 280 281 283 284 285 287 288 289]}; for ndata=randi(size(data,1),1,20) a=data{ndata,1}; N=numel(a); A=zeros(N); A(data{ndata,2})=1;A=A|A'; if rand<.5, idx=find(A); else idx=find(~A); end [b,c]=ind2sub(size(A),idx(randi(numel(idx)))); d=a;d([b c])=[]; [x,y]=meshgrid(d); z=[x(:) y(:)]; valid=y>x; assert(fivesteps(z(valid,:))==A(b,c),'failed on d = %s (correct output = %s)',mat2str(d),mat2str(A(b,c))); end

ans = 78 2 ans = 2 2 ans = 2 2 ans = 4 26 4 8 13 8

Output argument "valid" (and maybe others) not assigned during call to "fivesteps". Error in Test27 (line 37) assert(fivesteps(z(valid,:))==A(b,c),'failed on d = %s (correct output = %s)',mat2str(d),mat2str(A(b,c)));

Suggested Problems

More from this Author38

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!