Skip to content

Instantly share code, notes, and snippets.

@pablen
Created Dec 4, 2017
Embed
What would you like to do?
Advent of Code. Day 4. Part 2.
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