JSFiddle - React, Tailwind, and code Playground

by mmarcon

HTML

<section id="console">

</section>

JavaScript

var log = function (m) {
    $('#console').append('<p>' + m + '</p>');
}

var input = {
    teamsCount: 10,
    teams: [
        [1009, 2011],
        [1100, 2300],
        [1100, 2120],
        [1500, 2011],
        [1800, 2010],
        [1520, 2600],
        [1430, 2900],
        [1456, 2300],
        [1009, 2311],
        [1234, 1200]
    ],
    friend: 1009
};

var run = function (input) {
    var teamL, teamS, matrix, i, j, n;
    if (input && input.teamsCount && input.teams && input.teams.length === input.teamsCount && input.friend) {
        matrix = [];
        //Init matrix (1000x1000)
        for (i = 0; i < 1000; i++) {
            matrix [i] = [];
        }
        
        for (n = 0; n < input.teams.length; n++) {
            matrix [input.teams[n][0] - 1000] [input.teams[n][1] - 2000] = 1;
        }
        
        
        
        /*
        teamL = input.teams.slice(0).sort(function(a,b){
            if (a[0] !== b[0]) {
                return a[0] - b[0];
            }
            else {
                return a[1] - b[1];
            }
        });
        
        teamS = input.teams.slice(0).sort(function(a,b){
            if (a[1] !== b[1]) {
                return a[1] - b[1];
            }
            else {
                return a[0] - b[0];
            }
        });
        */
    }
    else {
        log('Input error');
    }
};

run (input);