{-# LANGUAGE BangPatterns #-}
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import Data.List
readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
f :: Char -> Int -> String -> [Int]
f c _ [] = []
f c n s = if head s == c then (n : f c (n+1) (tail s) ) else f c (n+1) (tail s)
g :: [Int] -> [Int] -> [Int] -> Int
g [] b c = 0
g _ [] c = 0
g _ b [] = 0
g a b c
| head a > head b = g a (tail b) c
| head b > head c = g a b (tail c)
| otherwise = 1 + g (tail a) (tail b) (tail c)
main = do
s <- getLine
let al = f 'A' 0 s
let bl = f 'B' 0 s
let cl = f 'C' 0 s
-- print al
print $ g al bl cl
Configuration is affected by the following files:
- cabal.project
- cabal.project.freeze
- cabal.project.local
app/Main.hs:2:1: warning: [GHC-66111] [-Wunused-imports]
The import of ‘Control.Monad’ is redundant
except perhaps to import instances from ‘Control.Monad’
To import instances alone, use: import Control.Monad()
|
2 | import Control.Monad
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/Main.hs:5:1: warning: [GHC-66111] [-Wunused-imports]
The import of ‘Data.List’ is redundant
except perhaps to import instances from ‘Data.List’
To import instances alone, use: import Data.List()
|
5 | import Data.List
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
app/Main.hs:6:1: warning: [GHC-38417] [-Wmissing-signatures]
Top-level binding with no type signature:
readInt :: BS.ByteString -> Int
|
6 | readInt = fst . fromJust . BS.readInt
| ^^^^^^^
app/Main.hs:6:1: warning: [GHC-40910] [-Wunused-top-binds]
Defined but not used: ‘readInt’
|
6 | readInt = fst . fromJust . BS.readInt
| ^^^^^^^
app/Main.hs:7:1: warning: [GHC-38417] [-Wmissing-signatures]
Top-level binding with no type signature:
readIntList :: BS.ByteString -> [Int]
|
7 | readIntList = map readInt . BS.words
| ^^^^^^^^^^^
app/Main.hs:7:1: warning: [GHC-40910] [-Wunused-top-binds]
Defined but not used: ‘readIntList’
|
7 | readIntList = map readInt . BS.words
| ^^^^^^^^^^^
app/Main.hs:8:1: warning: [GHC-38417] [-Wmissing-signatures]
Top-level binding with no type signature: getInt :: IO Int
|
8 | getInt = readInt <$> BS.getLine
| ^^^^^^
app/Main.hs:8:1: warning: [GHC-40910] [-Wunused-top-binds]
Defined but not used: ‘getInt’
|
8 | getInt = readInt <$> BS.getLine
| ^^^^^^
app/Main.hs:9:1: warning: [GHC-38417] [-Wmissing-signatures]
Top-level binding with no type signature: getIntList :: IO [Int]
|
9 | getIntList = readIntList <$> BS.getLine
| ^^^^^^^^^^
app/Main.hs:9:1: warning: [GHC-40910] [-Wunused-top-binds]
Defined but not used: ‘getIntList’
|
9 | getIntList = readIntList <$> BS.getLine
| ^^^^^^^^^^
app/Main.hs:11:3: warning: [GHC-40910] [-Wunused-matches]
Defined but not used: ‘c’
|
11 | f c _ [] = []
| ^
app/Main.hs:12:14: warning: [GHC-63394] [-Wx-partial]
In the use of ‘head’
(imported from Data.List, but defined in GHC.List):
"This is a partial function, it throws an error on empty lists. Use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
|
12 | f c n s = if head s == c then (n : f c (n+1) (tail s) ) else f c (n+1) (tail s)
| ^^^^
app/Main.hs:12:47: warning: [GHC-63394] [-Wx-partial]
In the use of ‘tail’
(imported from Data.List, but defined in GHC.List):
"This is a partial function, it throws an error on empty lists. Replace it with drop 1, or use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
|
12 | f c n s = if head s == c then (n : f c (n+1) (tail s) ) else f c (n+1) (tail s)
| ^^^^
app/Main.hs:12:73: warning: [GHC-63394] [-Wx-partial]
In the use of ‘tail’
(imported from Data.List, but defined in GHC.List):
"This is a partial function, it throws an error on empty lists. Replace it with drop 1, or use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
|
12 | f c n s = if head s == c then (n : f c (n+1) (tail s) ) else f c (n+1) (tail s)
| ^^^^
app/Main.hs:14:6: warning: [GHC-40910] [-Wunused-matches]
Defined but not used: ‘b’
|
14 | g [] b c = 0
| ^
app/Main.hs:14:8: warning: [GHC-40910] [-Wunused-matches]
Defined but not used: ‘c’
|
14 | g [] b c = 0
| ^
app/Main.hs:15:8: warning: [GHC-40910] [-Wunused-matches]
Defined but not used: ‘c’
|
15 | g _ [] c = 0
| ^
app/Main.hs:16:5: warning: [GHC-40910] [-Wunused-matches]
Defined but not used: ‘b’
|
16 | g _ b [] = 0
| ^
app/Main.hs:18:7: warning: [GHC-63394] [-Wx-partial]
In the use of ‘head’
(imported from Data.List, but defined in GHC.List):
"This is a partial function, it throws an error on empty lists. Use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
|
18 | | head a > head b = g a (tail b) c
| ^^^^
app/Main.hs:18:16: warning: [GHC-63394] [-Wx-partial]
In the use of ‘head’
(imported from Data.List, but defined in GHC.List):
"This is a partial function, it throws an error on empty lists. Use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
|
18 | | head a > head b = g a (tail b) c
| ^^^^
app/Main.hs:18:30: warning: [GHC-63394] [-Wx-partial]
In the use of ‘tail’
(imported from Data.List, but defined in GHC.List):
"This is a partial function, it throws an error on empty lists. Replace it with drop 1, or use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
|
18 | | head a > head b = g a (tail b) c
| ^^^^
app/Main.hs:19:7: warning: [GHC-63394] [-Wx-partial]
In the use of ‘head’
(imported from Data.List, but defined in GHC.List):
"This is a partial function, it throws an error on empty lists. Use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
|
19 | | head b > head c = g a b (tail c)
| ^^^^
app/Main.hs:19:16: warning: [GHC-63394] [-Wx-partial]
In the use of ‘head’
(imported from Data.List, but defined in GHC.List):
"This is a partial function, it throws an error on empty lists. Use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
|
19 | | head b > head c = g a b (tail c)
| ^^^^
app/Main.hs:19:32: warning: [GHC-63394] [-Wx-partial]
In the use of ‘tail’
(imported from Data.List, but defined in GHC.List):
"This is a partial function, it throws an error on empty lists. Replace it with drop 1, or use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
|
19 | | head b > head c = g a b (tail c)
| ^^^^
app/Main.hs:20:26: warning: [GHC-63394] [-Wx-partial]
In the use of ‘tail’
(imported from Data.List, but defined in GHC.List):
"This is a partial function, it throws an error on empty lists. Replace it with drop 1, or use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
|
20 | | otherwise = 1 + g (tail a) (tail b) (tail c)
| ^^^^
app/Main.hs:20:35: warning: [GHC-63394] [-Wx-partial]
In the use of ‘tail’
(imported from Data.List, but defined in GHC.List):
"This is a partial function, it throws an error on empty lists. Replace it with drop 1, or use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
|
20 | | otherwise = 1 + g (tail a) (tail b) (tail c)
| ^^^^
app/Main.hs:20:44: warning: [GHC-63394] [-Wx-partial]
In the use of ‘tail’
(imported from Data.List, but defined in GHC.List):
"This is a partial function, it throws an error on empty lists. Replace it with drop 1, or use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
|
20 | | otherwise = 1 + g (tail a) (tail b) (tail c)
| ^^^^
app/Main.hs:21:1: warning: [GHC-38417] [-Wmissing-signatures]
Top-level binding with no type signature: main :: IO ()
|
21 | main = do
| ^^^^
Configuration is affected by the following files:
- cabal.project
- cabal.project.freeze
- cabal.project.local