aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-333/hvukman/f#/333_p1.fs15
1 files changed, 15 insertions, 0 deletions
diff --git a/challenge-333/hvukman/f#/333_p1.fs b/challenge-333/hvukman/f#/333_p1.fs
new file mode 100644
index 0000000000..7bebaaf2ac
--- /dev/null
+++ b/challenge-333/hvukman/f#/333_p1.fs
@@ -0,0 +1,15 @@
+// 333 part 1
+
+let input = [ [|2;1|] ; [|2;3|] ; [|2;5|] ];
+let input2 = [ [|1;4|] ; [|3;4|] ; [|10;4|] ];
+let input3 = [ [|0;0|] ; [|1;1|] ; [|2;3|] ];
+let input4 = [ [|10000;10000|] ; [|20000;20000|] ; [|30000;30000|] ];
+let inputs_1 = [ input; input2 ; input3; input4]
+// -- calculated the determinant
+// -- https://de.wikipedia.org/wiki/Kollinearität#Analytische_Geometrie
+let det (x:int array list) = let x1,x2,x3 = x[0].[0],x[1].[0],x[2].[0]
+ let y1,y2,y3 = x[0].[1],x[1].[1],x[2].[1]
+ let det = x1*y2 + x2*y3 + x3*y1 - x1*y3 - x2*y1 - x3*y2
+ if det =0 then printf "%s\n" "true" else printf "%s\n" "false"
+
+