Input:
Output:
Example:
Example 1: n = 6, d = 1
g = [2 1 3 2 1].'; x = [3 10 15 8 5].'; y = [0 2 5 % y(1,2) = y(2,1) = min(10-3,5-3,10-8,8-5) = 2 2 0 7 % y(1,3) = y(3,1) = min(15-10,15-5) = 5 5 7 0]; % y(2,3) = y(3,2) = min(15-3,15-8) = 7
Example 2: n = 3, d = 2
g = [1 2 2].'; x = [0 0 5 12 3 4]; y = [0 5; 5 0]; % y(1,2) = y(2,1) = min(sqrt(5^2+12^2),sqrt(3^2+4^2)) = 5
Testing:
The test suite will focus mainly on the large-scale problem dimensions (e.g., large n and/or d). The purpose is to direct attention towards efficient runtime speed of execution. Note that your solution may run into a time-out error if it is not sufficiently efficient (which is why this problem falls into the Cody5:Hard category).
Scoring:
We have modified Cody's default size-based scoring function into a performance-based scoring system (implemented by our fellow Cody player LY Cao), in which the score of your submission equals 5 times the execution time of your solution (which reprents a score resolution of 0.2 seconds and allows for more room for performance improvement). Please ignore the code size and focus only on improving the code performance, as our test suite will reject any submissions running longer than 20 seconds (in contrast to Cody's default 40 seconds timeout limit).
Please be advised that an amazingly fast solution would earn a score < 5, meaning that it completes execution of all test cases within a second!
Update (11/21/2017): Additional test cases are added to ban cheater solutions (e.g., hard-coded submissions 1351541, 1351007, 1350563, 1349442, all came from Marco Tullio).
It's too bad that one stray wrong answer with an inordinately high score size ruins the scale of the solution graph. Is there any way to fix that?
Thanks for your feedback. That stray answer tried to hack the scoring in the test suite, and is now removed. Unfortunately, the current scale of the score map is still not good (hard to distinguish good solutions with score < 50). A possible workaround (from a user side) is to modify the scoring in the test suite to truncate the high scores (>=100) to 100, and the resulting y-axis scale would be [0,100] (which makes all solutions distinguishable). But this also results in a re-scoring of all solutions, which might change the current ranking of those similarly fast solutions (e.g., the current best two solutions have an equal score of 2)... I would appreciate any further suggestions (or comments from the Cody admin side) on this.
All problems should be scored by its speed rather than size imo.
leading solution is cheater solution: https://www.mathworks.com/matlabcentral/cody/problems/44353-group-wise-euclidean-distance/solutions/1391283
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.
What's the point to keep cheating?
Dis-allowed.
Hard-coded solutions are disallowed.
349 Solvers
Make an N-dimensional Multiplication Table
105 Solvers
Create a square matrix of multiples
323 Solvers
299 Solvers
43 Solvers