diff options
author | Tomasz Chojnacki <tomaszchojnacki2001@gmail.com> | 2023-02-22 13:34:58 +0100 |
---|---|---|
committer | Tomasz Chojnacki <tomaszchojnacki2001@gmail.com> | 2023-02-22 13:34:58 +0100 |
commit | 5746dbca0ddaef455b6f26fba3945f3533d0b2c1 (patch) | |
tree | 855e48c9d25a0136351947dfe17140d40568e8fd /aoc-2020-gleam/src/days/day02.gleam | |
parent | ed0763c9dce58a53715415f31146b6f670519d76 (diff) | |
download | gleam_aoc2020-5746dbca0ddaef455b6f26fba3945f3533d0b2c1.tar.gz gleam_aoc2020-5746dbca0ddaef455b6f26fba3945f3533d0b2c1.zip |
Add aliases to long imports
Diffstat (limited to 'aoc-2020-gleam/src/days/day02.gleam')
-rw-r--r-- | aoc-2020-gleam/src/days/day02.gleam | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/aoc-2020-gleam/src/days/day02.gleam b/aoc-2020-gleam/src/days/day02.gleam index 3f77384..6d2e743 100644 --- a/aoc-2020-gleam/src/days/day02.gleam +++ b/aoc-2020-gleam/src/days/day02.gleam @@ -1,9 +1,9 @@ import gleam/io import gleam/list -import gleam/string import gleam/bool -import ext/resultx +import gleam/string as str import ext/listx +import ext/resultx as resx import util/input_util import util/parser as p @@ -49,7 +49,7 @@ fn part1(lines: List(String)) -> Int { lines, fn(line) { line.password - |> string.to_graphemes + |> str.to_graphemes |> listx.count(satisfying: fn(g) { g == line.policy.grapheme }) |> fn(l) { line.policy.min <= l && l <= line.policy.max } }, @@ -60,10 +60,11 @@ fn part2(lines: List(String)) -> Int { solve( lines, fn(line) { - let graphemes = string.to_graphemes(line.password) let grapheme_matches = fn(idx) { - list.at(in: graphemes, get: idx - 1) - |> resultx.force_unwrap == line.policy.grapheme + line.password + |> str.to_graphemes + |> list.at(idx - 1) + |> resx.assert_unwrap == line.policy.grapheme } bool.exclusive_or( grapheme_matches(line.policy.min), |