Cody

Solution 1941675

Submitted on 18 Sep 2019 at 16:07 by Sean Kavanagh
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','!','system','unix'},'File','nchoosekFast.m')

2   Pass
v = rand(1,10); k = randi(10); assert(isequal(nchoosek(v,k),nchoosekFast(v,k)));

3   Pass
v = num2cell(randn(5,30),1); k = randi(4); assert(isequal(nchoosek(v,k),nchoosekFast(v,k)));

4   Pass
v = rand(1,100); assert(isequal(nchoosek(v,1),nchoosekFast(v,1),nchoosekFast(v,100)',v') && isempty(nchoosekFast(v,0)))

5   Pass
v = rand(1,29); t = tic; c = nchoosekFast(v,9); t = toc(t); assert(isequal(size(c),[10015005 9]) && ... all(ismember(c(:),v)) && ... size(unique(sort(c(randperm(end,1e6),:),2),'rows'),1) == 1e6) fid = fopen('score.p','Wb'); fwrite(fid,uint8(sscanf([... '7630312E30307630302E3030000B901C454EFFB100000031000001330000018D483A60'... '366BC9545F84AE26323B67424D4E8A7A2E5B7D8ACAA45A1C3C5C8B33E245C95243E3CB'... 'AF5D0D993BDA70B7AB5DA365A83E8CA87FFC45265E23EF80943784C5F48E6E53D5DA34'... 'F1F2ECD34683EABE3B7461DC9E8004CC50B2A79D73495F6F625B5365602B2E6C6093D2'... '997D371DA457CE82327E686AF512A507B2CB62A375BFD1B283DDD2C01EDEF2771EDAA3'... '6ABB4852BA4061E20149688E812EB41A9AF8627EF35755492D2830EB8718BCFE88027E'... '6EA960B63A3B3E26E0451B1DCF14F3C20E70D9D93B08E7FF4AE8D82E7CC38042FD38F7'... 'A14D312EF5652823FEB7E8B52AF5C69F5E7D16B116B5F979EDA77459D6BB61B7971A51'... '041227DD601319D667DF62E8DA5E381FDD07A2806FE835BD2569E5315CDFC19C6B6A2B'... '4F0FF6BA803F1759ACAB133CCFAB6D5A5D002FC2C5F381F0'],'%2X'))); fclose(fid); score(round(3*t))

Suggested Problems

More from this Author10