사랑하애오

솔루션

const solution = (score) => {
  const avgs = score.map(([a, b]) => (a + b) / 2);
  const avgRank = [...avgs]
    .sort((a, b) => b - a)
    .map((avg, i) => ({ avg, rank: i + 1 }))
    .map((a, i, arr) =>
      i > 0 && a.avg === arr[i - 1].avg ? { ...a, rank: arr[i - 1].rank } : a
    );
  console.log(avgRank);

  const answer = avgs.map(
    (_avg) => avgRank.find(({ avg }) => _avg === avg).rank
  );
  console.log(answer);

  return answer;
};

 

 

솔루션

const solution = (score) => {
  const answer = score.map((el) => {
    return (
      score.filter((v) => (v[0] + v[1]) / 2 > (el[0] + el[1]) / 2).length + 1
    );
  });
  console.log(answer);

  return answer;
};
profile

사랑하애오

@사랑하애

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!