After reading the question, a quick search on how to test if a point is in a triangle turned up this useful SO answer. Translating the algorithm to F# is pretty trivial:
I saved the triangle.txt file alongside the script file, so to make it easier to load and parse. The content of the file looks like this:
so for each line, we have the 3 (x,y) coordinates separated by comma.
F# 4 also added a chunkBySize combinator to the Array module, which comes in handy here:
This solution runs for 20ms on my machine.
The source code for this solution is here.
Subscribe to my newsletter and get new contents delivered straight to your inbox :-)