Skip to content

Instantly share code, notes, and snippets.

@SeanPlusPlus
Created March 14, 2019 02:27
Show Gist options
  • Save SeanPlusPlus/a8b603b8a90f226eb0cb2902c40389f2 to your computer and use it in GitHub Desktop.
Save SeanPlusPlus/a8b603b8a90f226eb0cb2902c40389f2 to your computer and use it in GitHub Desktop.
var arr = [
'James Harden, PG',
'Anthony Davis, PF',
'LeBron James, SF',
'Damian Lillard, PG',
'Giannis Antetokounmpo, PF',
'Kevin Durant, SF',
'Russell Westbrook, PG',
'Kyrie Irving, PG',
'LaMarcus Aldridge, C',
'Victor Oladipo, SG',
'DeMar DeRozan, SG',
'Joel Embiid, C',
'Bradley Beal, SG',
'Lou Williams, SG',
'Jimmy Butler, SG',
'Kemba Walker, PG',
'Paul George, SF',
'Blake Griffin, PF',
'CJ McCollum, SG',
'Karl-Anthony Towns, C',
]
var targets = [
'James Harden, PG',
'Kevin Durant, SF',
'Karl-Anthony Towns, C',
'Anthony Davis, PF',
]
const neighbor = (degree, idx, arr) => {
return [
arr[idx - degree],
arr[idx + degree]
]
}
for (var i = 0; i < arr.length; i++) {
for (var k = 0; k < targets.length; k++) {
var target = targets[k]
if (arr[i] === target) {
degree = 0
console.log(degree, '->', (arr[i]));
degree = 2
console.log(degree, '->', (neighbor(degree, i, arr)[0]));
console.log(degree, '->', (neighbor(degree, i, arr)[1]));
degree = 1
console.log(degree, '->', (neighbor(degree, i, arr)[0]));
console.log(degree, '->', (neighbor(degree, i, arr)[1]));
console.log('\n');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment