We approach the problem by finding the minimum number of triangles with a pair of edges of the same color; we call such triangles "isosceles". We can count the number of such triangles by instead considering:

The number of isosceles triangles is equal to the number of pairs of adjacent edges of the same color.

So, if we let $n_{i, v}$ denote the number of edges of the ith color touching vertex $v$, the number of isosceles triangles can be written as

$$
\sum_{v \text { vertex }} \sum_{i=1}^{8}\left(\begin{array}{c}
n_{i, v} \\
2
\end{array}\right)
$$

Since $\sum_{i=1}^{8} n_{i, v}=16$, by Jensen's Inequality we actually have

$$
\sum_{v \text { vertex }} \sum_{i=1}^{8}\left(\begin{array}{c}
n_{i, v} \\
2
\end{array}\right) \geq \sum_{v \text { vertex }} 8\left(\begin{array}{c}
16 / 8 \\
2
\end{array}\right)=17 \cdot 8=136
$$

So, the number of triangles with all different colors is at most $\left(\begin{array}{c}17 \\ 3\end{array}\right)-17 \cdot 8=544$. We leave the construction of a maximal example as an exercise to the reader.
Let $\mathcal{P}$ be a regular 17 -gon; we draw in the $\left(\begin{array}{c}17 \\ 2\end{array}\right)$ diagonals and sides of $\mathcal{P}$ and paint each side or diagonal one of eight different colors. Suppose that there is no triangle (with vertices among vertices of $\mathcal{P}$ ) whose three edges all have the same color. What is the maximum possible number of triangles, all of whose edges have different colors?