You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
587 B

import Part1
import Part2 (getSimilarityScore, getValueCounts)
import System.IO
main = do
inputs <- readFile "inputs.txt"
let (listA, listB) = parseFileString inputs
-- Solve part 1
let sortedListA = quickSort listA
let sortedListB = quickSort listB
let distances = [abs (a - b) | (a, b) <- zip sortedListA sortedListB]
let distance = sum distances
putStrLn "The solution to part 1 is: "
print distance
-- Solve part 2
let bMap = getValueCounts sortedListB
let score = getSimilarityScore sortedListA bMap
putStrLn "The solution to part 2 is: "
print score