{"size": 1286, "ext": "js", "max_stars_repo_path": "tournaments/chessTriangle/chessTriangle.js", "max_stars_repo_name": "gurfinkel/codeSignal", "max_stars_repo_stars_event_min_datetime": "2020-02-06T09:51:22.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-19T00:18:44.000Z", "max_issues_repo_path": "tournaments/chessTriangle/chessTriangle.js", "max_issues_repo_name": "gurfinkel/codeSignal", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tournaments/chessTriangle/chessTriangle.js", "max_forks_repo_name": "gurfinkel/codeSignal", "max_forks_repo_forks_event_min_datetime": "2019-09-27T13:06:21.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-20T23:13:17.000Z"}
{"max_stars_count": 5, "max_issues_count": null, "max_forks_count": 3, "avg_line_length": 25.72, "max_line_length": 78, "alphanum_fraction": 0.298600311}
function chessTriangle(n, m) {
    const onBoard = function(x,n,m) {
        return 1 <= x[0] && x[0] <= n && 1 <= x[1] && x[1] <= m;
    };
    
    const rookBishop = function(cell,n,m) {
        let move = 0;
        let moves = [[1,2],[2,1],[-1,-2],[-2,-1],[-1,2],[-2,1],[1,-2],[2,-1]];
        
        for (const x of moves) {
            if (onBoard([cell[0]+x[0],cell[1]+x[1]],n,m)) {
                const i = x[0];
                const j = x[1];
                
                if (onBoard([cell[0]+i,cell[1]+i],n,m)) {
                    ++move;
                }
                
                if (onBoard([cell[0]+j,cell[1]+j],n,m)) {
                    ++move;
                }
                
                if (onBoard([cell[0]+i,cell[1]-i],n,m)) {
                    ++move;
                }
                
                if (onBoard([cell[0]-j,cell[1]+j],n,m)) {
                    ++move;
                }
            }
        }
        
        return move;
    };
    
    if (1 === n || 1 === m || (3 > n && 3 > m)) {
        return 0;
    }
    
    let output = 0;
    
    for (let x = 1; n + 1 > x; ++x) {
        for (let y = 1; m + 1 > y; ++y) {
            output += rookBishop([x, y], n, m);
        }
    }
    
    return output << 1;
}
