Banned cheater solution.
if you are feeling overwhelmed by a particularly persistent cheater just know that you can ban a player from your own problems by adding to your testsuite something like: lines=textread('groupDist.m','%s'); id=str2num(regexp(lines{end},'\d+','match','once')); assert(~ismember(id,[123456789 234567890]),'banned player id'); (where the array in the ismember line contains the list of player ids that you want to ban from your problem -e.g. my player id is 1379371; please do not ban me :)
Many thanks Alfonso for your suggestion. I was just thinking if I can ban a persistent cheater based on the player id. What you suggested is exactly what I need. If this guy cheats one more time (which is getting harder now with my added pcode in the test suite), I will definitely ban the guy using your suggested code.
Test | Status | Code Input and Output |
---|---|---|
1 | Fail |
assessFunctionAbsence({'regexp','regexpi','regexprep','str2num','tic','toc','persistent','global','rng','assert','!','system','unix','noCheater'},'FileName','groupDist.m')
|
2 | Fail |
fid = fopen('noCheater.p','Wb');
fwrite(fid, hex2dec(reshape([
'7630312E30307630302E30300007701CAB777FB100000015000000740000007E3D5C20F'...'
'5319EEB8B0D3D9C9C87C18B91C13D7310D9D8E837C95E62D49A3FE08B071790DBC222B5'...
'839E9A19EA6AA7CF3785A7E7CEC1CFE46E0E9A5DB7C82D69A4FAB7BF308D0871C342A5F'...
'EF9AF61623F1D97F80207388D54ABA3CB3D551617DA33AA3F5040CD425FC9B29E2A4233'...
'AE7C5ADEF399'],2,[]).')); rehash path;
fclose(fid);
assert(noCheater(),'Cheater detected!')
|
3 | Fail |
g = [2 1 3 2 1].';
x = [3 10 15 8 5].';
y_correct = [0 2 5
2 0 7
5 7 0];
assert(isequaln(y_correct,groupDist(x,g)))
|
4 | Fail |
g = [1 2 2].';
x = [0 0
5 12
3 4];
y_correct = [0 5;
5 0];
assert(isequal(y_correct,groupDist(x,g)))
|
5 | Fail |
g = [2 2 3 3 3 1].';
x = [-5 12
3 4
-7 -24
25 4
9 40
0 0];
y_correct = [0 5 25;
5 0 22
25 22 0];
assert(isequal(y_correct,groupDist(x,g)))
|
6 | Fail |
g = randperm(10).';
x = rand(10,1);
a = sortrows([g,x]);
y_correct = abs(a(:,2)-a(:,2).');
assert(isequal(round(y_correct,10),round(groupDist(x,g),10)))
|
7 | Fail |
g = [1,2,3].';
x = [2,5,10].';
y_correct = [0 3 8
3 0 5
8 5 0];
assert(isequaln(y_correct,groupDist(x,g)))
|
8 | Fail |
global t
t = zeros(1,3);
rng(923,'twister');
n = 5e3; d = 3; m = 5;
x = rand(n,d);
g = randi(m,n,1);
y_correct = [0,0.00653919638188362,0.00319052186150122,0.00858841434457234,0.00359654235965771
0.00653919638188362,0,0.00855286615862212,0.00589790293838067,0.00484910151004134
0.00319052186150122,0.00855286615862212,0,0.00591041083080696,0.00483607360689871
0.00858841434457234,0.00589790293838067,0.00591041083080696,0,0.00695738487959094
0.00359654235965771,0.00484910151004134,0.00483607360689871,0.00695738487959094,0];
tic, y = groupDist(x,g); t(1) = toc;
assert(isequal(round(y_correct,10),round(y,10)))
|
9 | Fail |
global t
rng(123)
rng(max('cody5'),'combRecursive');
n = 5e3; d = 3; m = 100;
x = 10*rand(n,d);
g = randi(m,n,1);
tic, y = groupDist(x,g); t(2) = toc;
assert(norm(y-y.') < 1e-11 && all(~diag(y)) && all(size(y)==m) && abs(det(y)-0.030846735888559)<1e-8 &&...
abs(cond(y)-1.606720826682107e+04) < 1e-6 && abs(max(nonzeros(y))-1.058563379304832)<1e-10 &&...
abs(mean(nonzeros(y))-0.419901913602729)<1e-8)
|
10 | Fail |
global t
rng(sum('Cody5, Oct. 16, 2017'),'multFibonacci')
n = 5e3; d = 1e2; m = 100;
x = 5*randn(n,d) + 20;
g = randi(m,n,1);
tic, y = groupDist(x,g); t(3) = toc;
assert(norm(y-y.') < 1e-11 && all(~diag(y)) && all(size(y)==m) && ...
abs(cond(y)-2.024633860688276e+02) < 1e-8 && abs(max(nonzeros(y))-57.768463869822135)<1e-10 &&...
abs(mean(nonzeros(y))-53.852605466762945)<1e-8)
|
11 | Fail |
global t
fid = fopen('score.p','Wb');
fwrite(fid,uint8(sscanf([...
'7630312E30307630302E3030000B901C454EFFB100000031000001330000018D483A60'...
'366BC9545F84AE26323B67424D4E8A7A2E5B7D8ACAA45A1C3C5C8B33E245C95243E3CB'...
'AF5D0D993BDA70B7AB5DA365A83E8CA87FFC45265E23EF80943784C5F48E6E53D5DA34'...
'F1F2ECD34683EABE3B7461DC9E8004CC50B2A79D73495F6F625B5365602B2E6C6093D2'...
'997D371DA457CE82327E686AF512A507B2CB62A375BFD1B283DDD2C01EDEF2771EDAA3'...
'6ABB4852BA4061E20149688E812EB41A9AF8627EF35755492D2830EB8718BCFE88027E'...
'6EA960B63A3B3E26E0451B1DCF14F3C20E70D9D93B08E7FF4AE8D82E7CC38042FD38F7'...
'A14D312EF5652823FEB7E8B52AF5C69F5E7D16B116B5F979EDA77459D6BB61B7971A51'...
'041227DD601319D667DF62E8DA5E381FDD07A2806FE835BD2569E5315CDFC19C6B6A2B'...
'4F0FF6BA803F1759ACAB133CCFAB6D5A5D002FC2C5F381F0'],'%2X')));
fclose(fid);
score(round(5*sum(t)))
fprintf('The execution time of test case %d is %.5f seconds \n',[5:7;t])
fprintf('The total execution time is %.5f seconds \n',sum(t))
assert(sum(t)<20, 'Sorry, your solution is too slow. The execution time must not exceed 20 seconds.')
|
7276 Solvers
2936 Solvers
1879 Solvers
Golomb's self-describing sequence (based on Euler 341)
86 Solvers
99 Solvers