CEMC Banner

Problem of the Week
Problem D and Solution
Mapping the Beats 2

Problem

Streaming services often use artificial intelligence to recommend music. One way to do this is to represent song attributes and a listener’s preferences using numbers or points on a grid. Recommendations for a listener can then be made by looking for songs represented by points that are close in distance to the point representing the listener’s preferences.

A particular music app represents song attributes and listener preferences using two scores: Energy and Happiness, which are each integers from \(1\) to \(10\). Suppose that three songs are represented by the following points:

Song (Energy, Happiness)
\(A\) \((5,5)\)
\(B\) \((4,3)\)
\(C\) \((2,8)\)
  1. Denise’s song preference score is represented as \((6,4)\). Use the distance formula \(d=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}\) to calculate the distance from Denise’s song preference score to each song. Which of the three songs would the streaming service recommend to Denise?

  2. After an app update, a song is recommended if its distance from the listener’s score is most \(4\). How many different scores of \((E,H)\) could there be in the songs recommended to Denise?

Solution

  1. The distances from Denise to each song are calculated below.

    \[\begin{aligned} d_A&=\sqrt{(5-6)^2+(5-4)^2}\\ &=\sqrt{1+1}\\ &=\sqrt{2}\approx 1.414 \end{aligned}\] \[\begin{aligned} d_B&=\sqrt{(4-6)^2+(3-4)^2}\\ &=\sqrt{4+1}\\ &=\sqrt{5}\approx 2.236 \end{aligned}\] \[\begin{aligned} d_C&=\sqrt{(2-6)^2+(8-4)^2}\\ &=\sqrt{16+16}\\ &=\sqrt{32}\approx 5.657 \end{aligned}\] Since song \(A\) is closest to Denise, the streaming service would recommend song \(A\) to Denise.

  2. If the distance between \((E,H)\) and Denise is at most \(4\) then \[\begin{aligned} \sqrt{(E-6)^2+(H-4)^2} & \le 4\\ (E-6)^2+(H-4)^2& \le 16 \end{aligned}\] Since \(E\) and \(H\) are integers, then \((E-6)^2\) and \((H-4)^2\) must be perfect squares. The possibilities that sum to at most \(16\) are \(0+0\), \(0+1\), \(0+4\), \(0+9\), \(0+16\), \(1+1\), \(1+4\), \(1+9\), \(4+4\), \(4+9\). We summarize the possible values of \((E,H)\) in the following table, keeping in mind that \(E\) and \(H\) are each integers from \(1\) to \(10\).

    Values of \((E-6)^2\) and \((H-4)^2\) Possibilities for \((E,H)\) Number of Possibilities
    Both \(0\) \((6,4)\) \(1\)
    \(0\) and \(1\) \((6,5)\), \((6,3)\), \((7,4)\), \((5,4)\) \(4\)
    \(0\) and \(4\) \((6,6)\), \((6,2)\), \((8,4)\), \((4,4)\) \(4\)
    \(0\) and \(9\) \((6,7)\), \((6,1)\), \((9,4)\), \((3,4)\) \(4\)
    \(0\) and \(16\) \((6,8)\), \((10,4)\), \((2,4)\) \(3\)
    Both \(1\) \((7,5)\), \((7,3)\), \((5,5)\), \((5,3)\) \(4\)
    \(1\) and \(4\) \((7,6)\), \((7,2)\), \((5,6)\), \((5,2)\), \((8,5)\), \((8,3)\), \((4,5)\), \((4,3)\) \(8\)
    \(1\) and \(9\) \((7,7)\), \((7,1)\), \((5,7)\), \((5,1)\), \((9,5)\), \((9,3)\), \((3,5)\), \((3,3)\) \(8\)
    Both \(4\) \((8,6)\), \((8,2)\), \((4,6)\), \((4,2)\) \(4\)
    \(4\) and \(9\) \((8,7)\), \((8,1)\), \((4,7)\), \((4,1)\), \((9,6)\), \((9,2)\), \((3,6)\), \((3,2)\) \(8\)

    Therefore, in total there are \(1+4+4+4+3+4+8+8+4+8=48\) different scores that could be in the songs recommended to Denise.

    Note: To calculate this answer, we could also look at a circle of radius \(4\), centred at \((6,4)\). The points \((E,H)\) that we are looking for correspond to the points inside this circle with integer coordinates between \(1\) and \(10\).