diff --git a/1 - Introduction/25 - Compute the Area of a Polygon/viniciusfk9.hs b/1 - Introduction/25 - Compute the Area of a Polygon/viniciusfk9.hs new file mode 100644 index 0000000..f29246e --- /dev/null +++ b/1 - Introduction/25 - Compute the Area of a Polygon/viniciusfk9.hs @@ -0,0 +1,11 @@ +import Control.Monad + +f (p1, p2) (q1, q2) = fromIntegral (p1 * q2 - q1 * p2) + +area lst = 0.5 * fromIntegral (abs . sum $ zipWith f lst (tail lst)) + +main = do + n <- fmap (read::String->Int) getLine + func <- forM [1..n] (\_->do + fmap ((\[a, b]->(a,b)) . map (read::String->Int).words) getLine :: IO (Int, Int)) + putStrLn $ show (area (func ++ take 1 func)) diff --git a/1 - Introduction/9 - Sum of Odd Elements/sum_of_odd_elements.scala b/1 - Introduction/9 - Sum of Odd Elements/sum_of_odd_elements.scala new file mode 100644 index 0000000..6f32160 --- /dev/null +++ b/1 - Introduction/9 - Sum of Odd Elements/sum_of_odd_elements.scala @@ -0,0 +1 @@ +def f(arr:List[Int]):Int = arr.filter(_%2!=0).sum