-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbijele.hs
35 lines (28 loc) · 982 Bytes
/
bijele.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import Data.List (intercalate)
import Data.List.NonEmpty (NonEmpty ((:|)), (<|))
import qualified Data.List.NonEmpty as NE
main :: IO ()
main = interact (formatOutput . solve . parseInput)
-- helpers for parsing
splitOn' :: Char -> String -> NonEmpty String
splitOn' sep s = case s of { [] -> "" :| []; (part : remainder) -> if part == sep then "" <| splitOn' sep remainder else let head :| tail = splitOn' sep remainder in (part : head) :| tail}
splitOn :: Char -> String -> [String]
splitOn sep s = NE.toList (splitOn' sep s)
-- Define input and output here
type Input = [Int]
type Output = [Int]
formatOutput :: Output -> String
formatOutput nums = (unwords $ map show nums) ++ "\n"
parseInput :: String -> Input
parseInput rawInput = map read (splitOn ' ' rawInput)
solve :: Input -> Output
solve nums =
let
k = 1 - nums !! 0
q = 1 - nums !! 1
r = 2 - nums !! 2
b = 2 - nums !! 3
n = 2 - nums !! 4
p = 8 - nums !! 5
in
[k, q, r, b, n, p]