Created
May 15, 2019 23:12
-
-
Save miguelemosreverte/42eef098ded7d7556ebd95b3668e07c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE FlexibleInstances, UndecidableInstances, DuplicateRecordFields #-} | |
module Main where | |
import Control.Monad | |
import Data.Array | |
import Data.Bits | |
import Data.List | |
import Data.List.Split | |
--import Data.Set | |
import Debug.Trace | |
import System.Environment | |
import System.IO | |
import System.IO.Unsafe | |
-- divf :: a -> a -> b | |
p arr = fromIntegral $ length arr | |
divf a b = fromIntegral(a) / fromIntegral(b) | |
lengths a b = p a / p b | |
f predicate arr = filter (predicate) arr | |
-- Complete the plusMinus function below. | |
plusMinus arr = do | |
print $ plus | |
print $ minus | |
print $ zeroes | |
where | |
minus = lengths (f (<0) arr) arr | |
zeroes = lengths (f (==0) arr) arr | |
plus = lengths (f (>0) arr) arr | |
readMultipleLinesAsStringArray :: Int -> IO [String] | |
readMultipleLinesAsStringArray 0 = return [] | |
readMultipleLinesAsStringArray n = do | |
line <- getLine | |
rest <- readMultipleLinesAsStringArray(n - 1) | |
return (line : rest) | |
main :: IO() | |
main = do | |
n <- readLn :: IO Int | |
arrTemp <- getLine | |
let arr = Data.List.map (read :: String -> Int) . words $ arrTemp | |
plusMinus arr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment