A team of seven researchers has won a $1m (£606,000) prize offered by online movie rental company Netflix.
The challenge was to improve the way in which the company website predicted customers' movie preferences and recommended other films.
Since its launch three years ago, more than 51,000 contestants worldwide have tried to solve it.
The winning team, BellKor, met each other for the first time at an awards ceremony held in New York on Monday.
BellKor consisted of former rivals who decided to work together to solve the problem. It included researchers from Austria and Montreal.
The criterion for the prize was that the winning solution had to improve the accuracy of recommendations by at least 10%.
"We had a bona fide race right to the very end," said Netflix chief executive Reed Hastings.
"Teams that had previously battled it out independently joined forces to surpass the 10% barrier. New submissions arrived fast and furious in the closing hours."
A matter of timing
The prize has long been a source of great excitement to fans of algorithms, but now it may also catch the eye of online businesses which rely on customer preferences to recommend products.
BellKor narrowly beat another team called Ensemble to the $1m jackpot. Both ended up with an overall improvement score of 10.06%.
However BellKor won because it had submitted its entry first - just 10 minutes earlier.