Created
December 4, 2017 12:39
-
-
Save pablen/9ea3b41d9bfdabfa1c96313a4c989117 to your computer and use it in GitHub Desktop.
Advent of Code. Day 4. Part 2.
This file contains hidden or 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
module Main exposing (..) | |
import Html exposing (text) | |
import Set | |
input : String | |
input = | |
"""pphsv ojtou brvhsj cer ntfhlra udeh ccgtyzc zoyzmh jum lugbnk | |
{-- more lines... --} | |
""" | |
isValidPassPhrase : String -> Bool | |
isValidPassPhrase line = | |
let | |
wordsCount = | |
line | |
|> String.words | |
|> List.length | |
filteredCount = | |
line | |
|> String.words | |
|> List.map (String.toList >> List.sort >> String.fromList) | |
|> Set.fromList | |
|> Set.size | |
in | |
wordsCount == filteredCount | |
main : Html.Html msg | |
main = | |
input | |
|> String.lines | |
|> List.filter isValidPassPhrase | |
|> List.length | |
|> toString | |
|> text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment