Cody

Solution 1334523

Submitted on 11 Nov 2017 by yurenchu
  • Size: 13
  • This is the leading solution.
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
n = 1:5; twins_corr = [3, 5, 11, 17, 29; 5, 7, 13, 19, 31]; assert(isequal(twin_primes(n),twins_corr))

ans = 3 5 11 17 29 5 7 13 19 31

2   Pass
n = 1:10; twins_corr = [3, 5, 11, 17, 29, 41, 59, 71, 101, 107; 5, 7, 13, 19, 31, 43, 61, 73, 103, 109]; assert(isequal(twin_primes(n),twins_corr))

ans = 3 5 11 17 29 41 59 71 101 107 5 7 13 19 31 43 61 73 103 109

3   Pass
n = 1:25; twins_corr = [3, 5, 11, 17, 29, 41, 59, 71, 101, 107, 137, 149, 179, 191, 197, 227, 239, 269, 281, 311, 347, 419, 431, 461, 521; 5, 7, 13, 19, 31, 43, 61, 73, 103, 109, 139, 151, 181, 193, 199, 229, 241, 271, 283, 313, 349, 421, 433, 463, 523]; assert(isequal(twin_primes(n),twins_corr))

ans = 3 5 11 17 29 41 59 71 101 107 137 149 179 191 197 227 239 269 281 311 347 419 431 461 521 5 7 13 19 31 43 61 73 103 109 139 151 181 193 199 229 241 271 283 313 349 421 433 463 523

4   Pass
n = 1:51; twins_corr = [3, 5, 11, 17, 29, 41, 59, 71, 101, 107, 137, 149, 179, 191, 197, 227, 239, 269, 281, 311, 347, 419, 431, 461, 521, 569, 599, 617, 641, 659, 809, 821, 827, 857, 881, 1019, 1031, 1049, 1061, 1091, 1151, 1229, 1277, 1289, 1301, 1319, 1427, 1451, 1481, 1487, 1607; 5, 7, 13, 19, 31, 43, 61, 73, 103, 109, 139, 151, 181, 193, 199, 229, 241, 271, 283, 313, 349, 421, 433, 463, 523, 571, 601, 619, 643, 661, 811, 823, 829, 859, 883, 1021, 1033, 1051, 1063, 1093, 1153, 1231, 1279, 1291, 1303, 1321, 1429, 1453, 1483, 1489, 1609]; assert(isequal(twin_primes(n),twins_corr))

ans = Columns 1 through 14 3 5 11 17 29 41 59 71 101 107 137 149 179 191 5 7 13 19 31 43 61 73 103 109 139 151 181 193 Columns 15 through 28 197 227 239 269 281 311 347 419 431 461 521 569 599 617 199 229 241 271 283 313 349 421 433 463 523 571 601 619 Columns 29 through 42 641 659 809 821 827 857 881 1019 1031 1049 1061 1091 1151 1229 643 661 811 823 829 859 883 1021 1033 1051 1063 1093 1153 1231 Columns 43 through 51 1277 1289 1301 1319 1427 1451 1481 1487 1607 1279 1291 1303 1321 1429 1453 1483 1489 1609

5   Pass
n = 10:29; twins_corr = [107, 137, 149, 179, 191, 197, 227, 239, 269, 281, 311, 347, 419, 431, 461, 521, 569, 599, 617, 641; 109, 139, 151, 181, 193, 199, 229, 241, 271, 283, 313, 349, 421, 433, 463, 523, 571, 601, 619, 643]; assert(isequal(twin_primes(n),twins_corr))

ans = 107 137 149 179 191 197 227 239 269 281 311 347 419 431 461 521 569 599 617 641 109 139 151 181 193 199 229 241 271 283 313 349 421 433 463 523 571 601 619 643

6   Pass
n = 2:8; twins_corr = [5, 11, 17, 29, 41, 59, 71; 7, 13, 19, 31, 43, 61, 73]; assert(isequal(twin_primes(n),twins_corr))

ans = 5 11 17 29 41 59 71 7 13 19 31 43 61 73

7   Pass
n = 35:42; twins_corr = [881, 1019, 1031, 1049, 1061, 1091, 1151, 1229; 883, 1021, 1033, 1051, 1063, 1093, 1153, 1231]; assert(isequal(twin_primes(n),twins_corr))

ans = 881 1019 1031 1049 1061 1091 1151 1229 883 1021 1033 1051 1063 1093 1153 1231

8   Pass
n = 34:47; twins_corr = [857, 881, 1019, 1031, 1049, 1061, 1091, 1151, 1229, 1277, 1289, 1301, 1319, 1427; 859, 883, 1021, 1033, 1051, 1063, 1093, 1153, 1231, 1279, 1291, 1303, 1321, 1429]; assert(isequal(twin_primes(n),twins_corr))

ans = 857 881 1019 1031 1049 1061 1091 1151 1229 1277 1289 1301 1319 1427 859 883 1021 1033 1051 1063 1093 1153 1231 1279 1291 1303 1321 1429

9   Pass
n = 9:-1:4; twins_corr = [101, 71, 59, 41, 29, 17; 103, 73, 61, 43, 31, 19]; assert(isequal(twin_primes(n),twins_corr))

ans = 101 71 59 41 29 17 103 73 61 43 31 19

Suggested Problems

More from this Author161