Now for the contest results.
Announcing the Winner:
Haron with his calculation of 28,350!
Congratulations on your 15M gold and well done with your maths skills
There was a great response to this contest and many great conversations about combinations, permutations and calculations. Shaydo and I thoroughly enjoyed this contest and I'm sure we will have more in the future.
Here is how we arrived at the final answer:
We started by using the ports list found on the active ports page: Caspian=1, Neapolis=2, Seaglory=3...
This is convenient because they are arranged by resource.
Shaydo used his programming skills to create a Visual Basic script to list every possible combination of ports and then wrote the program to sift through the list and identify illegal routes and duplicate routes. At first his program was taking hours just to check a few thousand routes so he made some improvements and managed to reach a list of routes within a few hours of running the script.
Captain D took a slightly different approach since he has far inferior programming skills and only knows a little bit of lua scripting. He first compiled every combination including silly routes like the same port 4 times in a row, then scripted the program to check each route against 5 criteria to remove duplicates and illegal routes. The following are the 5 rules that valid 4-port trade routes in Avonmora need to follow: (2 & 3-port routes were calculated separately)
21*21*21*21= 194,481 total routes
1) no repeated ports immediately after one another: 34,461 routes removed
2) no repeated resources (ie no 2 rum ports one immediately after another): 54,558 routes removed
3) no 2-port routes in disguise (no Tortuga-Tzogos-Tortuga-Tzogos): 378 routes removed
4) no rotated routes (1-4-7-10 & 10-1-4-7) the program limits the 2nd, 3rd and 4th ports to be greater than the first port. If any of the 2nd, 3rd or 4th ports were less than the first then the route could be rotated so that the lowest number is first which would be a duplicate of another route: 77,679 routes removed
5) no rotated 3-port routes (1-4-1-5 & 1-5-1-4) this means the 4th port must be greater than the 2nd port when the 1st & 3rd ports are the same: 1,134 ports removed
4-port routes total 26,271
3-port routes follow the same type of rules: no repeat ports or resources and the 2nd and 3rd ports must be greater than the 1st port.
3-port routes total 1,890
2-port routes are quite a bit easier since they can can only be duplicated by flipping the 1st & 2nd ports (Kanoni-Baramas & Baramas-Kanoni). 21*18/2
2-port routes total 189
Therefore there are 28,350 total valid routes in Avonmora.
Shaydo compared the 2 separately created lists and they match exactly and also match Haron's logic which gives us great confidence that we have a correct list.
Haron has posted some excellent explanations on how to arrive at these same numbers without using programming.
Honorable mention goes to PhoenixKnight and Slindur who estimated within 3% and 8% of the correct number.
Let us know what other competitions might be fun! We will provide the prize money.
Maybe the Travelling Salesman Problem?
Shaydo (#22355) and Captain Dungeness (#3397)