diff options
author | H.J <thechairman@thechairman.info> | 2024-10-09 11:36:55 -0400 |
---|---|---|
committer | H.J <thechairman@thechairman.info> | 2024-10-09 11:36:55 -0400 |
commit | 8777ff071f7bb37631baa7b6717ad29961e50911 (patch) | |
tree | 6d59c4ed58e454b960339c3d1151f0a879e8d7cb /aoc2017-gleam/src/aoc_2017/day_4.gleam | |
parent | 6156a9ef7be4012063a042aafb4e9b0d7eadde8e (diff) | |
download | gleam_aoc-8777ff071f7bb37631baa7b6717ad29961e50911.tar.gz gleam_aoc-8777ff071f7bb37631baa7b6717ad29961e50911.zip |
sorting by language
Diffstat (limited to 'aoc2017-gleam/src/aoc_2017/day_4.gleam')
-rw-r--r-- | aoc2017-gleam/src/aoc_2017/day_4.gleam | 31 |
1 files changed, 0 insertions, 31 deletions
diff --git a/aoc2017-gleam/src/aoc_2017/day_4.gleam b/aoc2017-gleam/src/aoc_2017/day_4.gleam deleted file mode 100644 index 9bc4f9a..0000000 --- a/aoc2017-gleam/src/aoc_2017/day_4.gleam +++ /dev/null @@ -1,31 +0,0 @@ -import gleam/list -import gleam/string - -pub fn parse(input: String) -> List(List(String)) { - use row <- list.map(string.split(input, "\n")) - string.split(row, " ") -} - -pub fn pt_1(input: List(List(String))) { - use acc, passwords <- list.fold(input, 0) - case passwords == list.unique(passwords) { - True -> acc + 1 - False -> acc - } -} - -pub fn pt_2(input: List(List(String))) { - use acc, passwords <- list.fold(input, 0) - let sorted_passwords = list.map(passwords, sort_graphemes) - case sorted_passwords == list.unique(sorted_passwords) { - True -> acc + 1 - False -> acc - } -} - -fn sort_graphemes(word: String) -> String { - word - |> string.to_graphemes - |> list.sort(string.compare) - |> string.concat -} |