Cody

Solution 2159360

Submitted on 13 Mar 2020 by Asif Newaz
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
%{ ╔═════════════════════════════════════════════════════════════╗ ║ Please note that problems in this series are designed for ║ ║ optimizing the code performance, rather than the usual Cody ║ ║ "size". We are achieving this goal by courtesy of LY Cao's ║ ║ new scoring function, which automatically grants a better ║ ║ score to a faster solution. Kindly note that simply using ║ ║ the conv function may result in a poor score or even failure║ ║ in one of the tests. Suggestions and comments are welcome. ║ ║ ║ ║ Thanks & have fun! ║ ║ Peng ║ ╚═════════════════════════════════════════════════════════════╝ %}

2   Pass
fid = fopen('EvaluateSolution.p','wb'); fwrite(fid,uint8(sscanf('7630312E30307630302E30300005B01CF7473FB1000000B50000010D000001A93014D309F9979F2A2C808C4F104ACA1480D0378FBCF4FF1C4C94A38C84A4969D0A597F5F12C8D564E7CD9584DF8BDD849A3B8C5FDEB66A3837A064275728B38736860BB79ABC4B3091D37C9A2010BE0378E708E59716738F85AA4AEBC8982C45E6CD45BAD19BD043D16D5834122D405752633CE6BD78ABA0676336E7BCDD4F2E181FF1CE8E9165F6BF30D850ED74385A40BDEB73AD82518B4CF2BB034951B1D23D360EDF335C22C209AAB3857BCEF61D192170FDE9D5449721A6B6DD082257E430059753696F1C5CD66E6B09AD24270B0335E830203EACA5BDF3E2A57620D5DB44A96AFCDE0387EF112F2A83FBF90E4AF09F9D4FCAA22134055610D0F7B55568D50A52CD5C46A3F0CA655C1B68','%2x'))); fclose(fid);

3   Pass
u = 1; v = 1; y_correct = 1; assert(isequal(fconv1f(u,v),y_correct))

ans = 1

4   Pass
u = 1:10; v = 1:5; y_correct = [1,4,10,20,35,50,65,80,95,110,114,106,85,50]; assert(all(abs(fconv1f(u,v)-y_correct)<1e-10))

ans = 1 4 10 20 35 50 65 80 95 110 114 106 85 50

5   Pass
u = [2 -4 0 1].'; v = [1:5].'; y_correct = [2,0,-2,-3,-4,-17,4,5].'; assert(all(abs(fconv1f(u,v)-y_correct)<1e-10))

ans = 2 0 -2 -3 -4 -17 4 5

6   Pass
u = rand(20,1); v = rand(10,1); y_correct = conv(u,v,'full'); assert(all(abs(fconv1f(u,v)-y_correct)<1e-10))

ans = 0.2183 0.6223 0.2812 0.8961 1.4384 0.6086 0.9863 1.2129 1.5515 1.5871 1.6435 1.6241 1.6606 1.3799 1.0884 1.0160 1.0385 1.3651 1.0657 1.6154 0.4952 0.5888 1.1261 0.6706 0.5269 0.2740 0.6816 0.4227 0.7017

7   Pass
% Large data size global sol_score u = rand(8e5,1); v = rand(1e5,1); t = builtin('tic'); y = fconv1f(u,v); sol_score = 50*builtin('toc',t); AbsTol = 1e-6; % Maximum absolute error tolerance pass = EvaluateSolution(u,v,y,AbsTol); assert(pass);

ans = 1.0e+04 * 0.0001 0.0001 0.0001 0.0001 0.0001 0.0001 0.0002 0.0001 0.0001 0.0002 0.0002 0.0003 0.0002 0.0003 0.0003 0.0003 0.0003 0.0004 0.0004 0.0004 0.0004 0.0005 0.0005 0.0005 0.0005 0.0005 0.0006 0.0006 0.0007 0.0007 0.0007 0.0006 0.0007 0.0008 0.0008 0.0008 0.0008 0.0009 0.0009 0.0009 0.0009 0.0009 0.0008 0.0009 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0011 0.0011 0.0011 0.0012 0.0013 0.0011 0.0011 0.0013 0.0013 0.0013 0.0012 0.0013 0.0014 0.0013 0.0014 0.0015 0.0014 0.0015 0.0016 0.0016 0.0015 0.0017 0.0017 0.0015 0.0017 0.0017 0.0017 0.0017 0.0017 0.0018 0.0017 0.0018 0.0019 0.0021 0.0020 0.0020 0.0020 0.0019 0.0021 0.0021 0.0022 0.0020 0.0021 0.0023 0.0023 0.0022 0.0021 0.0023 0.0023 0.0023 0.0025 0.0025 0.0024 0.0024 0.0025 0.0025 0.0024 0.0026 0.0025 0.0027 0.0027 0.0026 0.0028 0.0026 0.0027 0.0028 0.0028 0.0029 0.0029 0.0029 0.0031 0.0030 0.0029 0.0031 0.0028 0.0031 0.0032 0.0030 0.0032 0.0030 0.0032 0.0031 0.0032 0.0032 0.0033 0.0035 0.0035 0.0035 0.0033 0.0036 0.0035 0.0035 0.0037 0.0036 0.0035 0.0037 0.0036 0.0038 0.0039 0.0037 0.0038 0.0037 0.0039 0.0040 0.0038 0.0037 0.0040 0.0038 0.0040 0.0040 0.0038 0.0040 0.0039 0.0041 0.0040 0.0041 0.0041 0.0042 0.0041 0.0042 0.0043 0.0041 0.0041 0.0041 0.0044 0.0042 0.0043 0.0044 0.0044 0.0043 0.0042 0.0042 0.0043 0.0044 0.0045 0.0045 0.0047 0.0043 0.0044 0.0045 0.0044 0.0044 0.0047 0.0049 0.0048 0.0045 0.0047 0.0047 0.0047 0.0048 0.0049 0.0049 0.0048 0.0048 0.0049 0.0051 0.0049 0.0049 0.0050 0.0050 0.0051 0.0050 0.0051 0.0050 0.0052 0.0053 0.0053 0.0051 0.0053 0.0055 0.0054 0.0052 0.0055 0.0054 0.0053 0.0055 0.0056 0.0057 0.0054 0.0055 0.0058 0.0058 0.0057 0.0059 0.0058 0.0057 0.0057 0.0057 0.0059 0.0060 0.0061 0.0060 0.0061 0.0060 0.0060 0.0059 0.0060 0.0060 0.0059 0.0060 0.0062 0.0061 0.0063 0.0063 0.0063 0.0061 0.0061 0.0063 0.0065 0.0064 0.0065 0.0065 0.0066 0.0062 0.0066 0.0063 0.0065 0.0064 0.0067 0.0067 0.0066 0.0064 0.0069 0.0068 0.0067 0.0065 0.0069 0.0066 0.0067 0.0070 0.0072 0.0070 0.0069 0.0069 0.0071 0.0068 0.0072 0.0072 0.0071 0.0072 0.0074 0.0072 0.0071 0.0072 0.0071 0.0073 0.0073 0.0071 0.0071 0.0072 0.0072 0.0073 0.0074 0.0074 0.0076 0.0074 0.0076 0.0076 0.0073 0.0076 0.0078 0.0081 0.0076 0.0075 0.0078 0.0078 0.0077 0.0078 0.0080 0.0080 0.0076 0.0081 0.0080 0.0080 0.0079 0.0081 0.0083 0.0079 0.0083 0.0083 0.0086 0.0084 0.0084 0.0084 0.0084 0.0084 0.0086 0.0086 0.0087 0.0083 0.0087 0.0088 0.0087 0.0087 0.0089 0.0087 0.0087 0.0087 0.0089 0.0088 0.0085 0.0086 0.0092 0.0087 0.0088 0.0091 0.0088 0.0090 0.0089 0.0090 0.0091 0.0093 0.0092 0.0094 0.0091 0.0092 0.0096 0.0091 0.0093 0.0092 0.0094 0.0096 0.0093 0.0096 0.0095 0.0097 0.0092 0.0096 0.0097 0.0097 0.0096 0.0099 0.0096 0.0097 0.0094 0.0097 0.0098 0.0099 0.0096 0.0100 0.0098 0.0102 0.0099 0.0099 0.0100 0.0103 0.0102 0.0102 0.0103 0.0102 0.0100 0.0101 0.0102 0.0101 0.0101 0.0103 0.0107 0.0103 0.0103 0.0104 0.0102 0.0102 0.0104 0.0106 0.0107 0.0106 0.0108 0.0106 0.0105 0.0104 0.0108 0.0106 0.0106 0.0109 0.0108 0.0104 0.0107 0.0108 0.0112 0.0109 0.0106 0.0108 0.0110 0.0108 0.0109 0.0108 0.0109 0.0109 0.0112 0.0116 0.0113 0.0113 0.0112 0.0115 0.0114 0.0113 0.0117 0.0118 0.0115 0.0119 0.0115 0.0119 0.0115 0.0114 0.0116 0.0119 0.0115 0.0118 0.0118 0.0118 0.0117 0.0116 0.0120 0.0121 0.0119 0.0123 0.0120 0.0122 0.0121 0.0121 0.0122 0.0123 0.0121 0.0121 0.0123 0.0124 0.0124 0.0127 0.0121 0.0122 0.0124 0.0123 0.0126 0.0121 0.0126 0.0123 0.0124 0.0124 0.0125 0.0124 0.0130 0.0124 0.0129 0.0126 0.0126 0.0130 0.0128 0.0129 0.0128 0.0128 0.0129 0.0129 0.0129 0.0131 0.0129 0.0130 0.0132 0.0131 0.0133 0.0131 0.0132 0.0133 0.0132 0.0133 0.0135 0.0131 0.0133 0.0136 0.0133 0.0136 0.0130 0.0132 0.0132 0.0137 0.0136 0.0139 0.0135 0.0133 0.0136 0.0138 0.0136 0.0138 0.0136 0.0138 0.0139 0.0139 0.0139 0.0141 0.0138 0.0141 0.0139 0.0137 0.0137 0.0138 0.0142 0.0137 0.0141 0.0136 0.0142 0.0145 0.0143 0.0140 0.0141 0.0138 0.0143 0.0142 0.0145 0.0143 0.0146 0.0144 0.0149 0.0146 0.0145 0.0143 0.0144 0.0147 0.0149 0.0146 0.0143 0.0144 0.0148 0.0145 0.0144 0.0140 0.0147 0.0146 0.0147 0.0145 0.0145 0.0150 0.0148 0.0149 0.0151 0.0151 0.0151 0.0149 0.0154 0.0152 0.0152 0.0151 0.0154 0.0150 0.0154 0.0151 0.0151 0.0155 0.0150 0.0152 0.0151 0.0152 0.0155 0.0151 0.0153 0.0153 0.0154 0.0153 0.0156 0.0156 0.0155 0.0157 0.0151 0.0155 0.0157 0.0155 0.0156 0.0153 0.0156 0.0156 0.0158 0.0155 0.0158 0.0156 0.0158 0.0157 0.0160 0.0160 0.0155 0.0158 0.0160 0.0162 0.0164 0.0161 0.0165 0.0160 0.0164 0.0162 0.0164 0.0166 0.0166 0.0161 0.0166 0.0165 0.0162 0.0162 0.0167 0.0166 0.0164 0.0164 0.0161 0.0164 0.0164 0.0166 0.0166 0.0163 0.0170 0.0166 0.0165 0.0165 0.0168 0.0167 0.0174 0.0170 0.0167 0.0169 0.0171 0.0165 0.0170 0.0170 0.0167 0.0169 0.0172 0.0172 0.0173 0.0173 0.0172 0.0171 0.0171 0.0177 0.0173 0.0171 0.0169 0.0175 0.0171 0.0173 0.0175 0.0174 0.0177 0.0176 0.0172 0.0176 0.0174 0.0175 0.0180 0.0178 0.0178 0.0179 0.0178 0.0177 0.0181 0.0179 0.0178 0.0176 0.0182 0.0182 0.0183 0.0181 0.0184 0.0181 0.0180 0.0183 0.0181 0.0184 0.0182 0.0186 0.0183 0.0187 0.0183 0.0182 0.0186 0.0185 0.0187 0.0184 0.0184 0.0189 0.0188 0.0187 0.0187 0.0186 0.0185 0.0187 0.0187 0.0189 0.0188 0.0184 0.0188 0.0193 0.0187 0.0187 0.0186 0.0189 0.0189 0.0192 0.0188 0.0192 0.0189 0.0194 0.0195 0.0195 0.0193 0.0196 0.0194 0.0194 0.0195 0.0195 0.0196 0.0198 0.0197 0.0198 0.0193 0.0195 0.0198 0.0198 0.0199 0.0195 0.0199 0.0196 0.0200 0.0200 0.0192 0.0200 0.0199 0.0202 0.0201 0.0198 0.0202 0.0201 0.0200 0.0203 0.0203 0.0199 0.0200 0.0200 0.0204 0.0204 0.0205 0.0200 0.0204 0.0201 0.0201 0.0204 0.0201 0.0202 0.0208 0.0201 0.0201 0.0205 0.0204 0.0205 0.0206 0.0211 0.0207 0.0207 0.0206 0.0206 0.0208 0.0206 0.0210 0.0207 0.0208 0.0210 0.0210 0.0208 0.0206 0.0205 0.0209 0.0211 0.0210 0.0209 0.0210 0.0211 0.0210 0.0215 0.0217 0.0211 0.0214 0.0216 0.0214 0.0215 0.0216 0.0215 0.0217 0.0215 0.0214 0.0217 0.0211 0.0217 0.0213 0.0214 0.0216 0.0215 0.0218 0.0220 0.0215 0.0216 0.0212 0.0217 0.0217 0.0215 0.0219 0.0218 0.0219 0.0221 0.0219 0.0223 0.0219 0.0222 0.0223 0.0221 0.0220 0.0223 0.0220 0.0220 0.0219 0.0221 0.0220 0.0221 0.0216 0.0221 0.0223 0.0219 0.0224 0.0223 0.0227 0.0225 0.0223 0.0226 0.0226 0.0224 0.0225 0.0226 0.0228 0.0230 0.0227 0.0229 0.0223 0.0228 0.0227 0.0227 0.0225 0.0228 0.0228 0.0229 0.0227 0.0229 0.0232 0.0231 0.0227 0.0231 0.0229 0.0237 0.0234 0.0236 0.0232 0.0231 0.0230 ...

8   Pass
% New scoring function by LY Cao global sol_score fid = fopen('score.p','wb'); fwrite(fid,sscanf('7630312E30307630302E30300008501CD77E9FB100000035000001110000018422762999A8C1DE50537BEE443F4D73651F830FC6C78ADFB7DF68DF98823F565884DC58E21C7E397E3D26E4FFEA9A0D83589ABB5C0B0B553B44CFD79C9B272D11DF1965AD538598E8319529727DF4C4CF36A6016DD7816544AE5A8F64C9B2D9D0C4B94DD5EDF14595CBFE3D402647499EA3D9D125AC927454ED85973BCD1AAEA536D5A6CDDCD78A0211E8179603FFE12E4AB0E4704EA195704428700BAE5C4DFD42FF1A8760EDF2721F9724498ECC9F957735E7A3CDB9630DB17DF92ACE8F486706020E0A8D022D14BC313879724760AE20D67F572DD85211E4BEA45CDF3E22976253F113AEA96C1FF907329E4BD429BCFC6331077DA21F05D791DA6ECCF680D2E23AC77DFCE5C1D9869D3098F5B89FF92A','%2x')); fclose(fid); score(sol_score);