aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJ.J <thechairman@thechairman.info>2023-12-03 12:22:07 -0500
committerJ.J <thechairman@thechairman.info>2023-12-03 12:22:07 -0500
commitcd893a2756ffcc73df737a154ea7b3e2119329fe (patch)
tree4c7758f7ba610a99d3a5d29cc1a8e976ba8f3f91
parent03a8465fef75336989ff7d20050b643e541e5a36 (diff)
downloadgleam_aoc-cd893a2756ffcc73df737a154ea7b3e2119329fe.tar.gz
gleam_aoc-cd893a2756ffcc73df737a154ea7b3e2119329fe.zip
testing
-rw-r--r--aoc2023/src/.gitignore1
-rw-r--r--aoc2023/src/aoc2023.gleam86
2 files changed, 0 insertions, 87 deletions
diff --git a/aoc2023/src/.gitignore b/aoc2023/src/.gitignore
index d9408e9..bc13a69 100644
--- a/aoc2023/src/.gitignore
+++ b/aoc2023/src/.gitignore
@@ -1,2 +1 @@
-input.txt
aoc2023.gleam \ No newline at end of file
diff --git a/aoc2023/src/aoc2023.gleam b/aoc2023/src/aoc2023.gleam
index 9fb5213..ea5c211 100644
--- a/aoc2023/src/aoc2023.gleam
+++ b/aoc2023/src/aoc2023.gleam
@@ -1,91 +1,5 @@
import gleam/io
-import gleam/string
-import gleam/list
-import gleam/int
pub fn main() {
io.println("Hello from aoc2023!")
}
-
-type Symbol {
- Period
- Symbol(String)
- Number(Int)
-}
-
-type CoordItem {
- CoordItem(List(#(Int, Int)), Symbol)
-}
-
-fn parse_grid1(input: String) {
- use line, x_coord <- list.index_map(string.split(input, "\n"))
- use char, y_coord <- list.index_map(string.to_graphemes(line), [])
- case char {
- "." -> [CoordItem([#(x_coord, y_coord)], Period), ..acc]
- x -> {
- case int.parse(x) {
- Error(_) -> [CoordItem([#(x_coord, y_coord)], Symbol(x)), ..acc]
- Ok(n) -> {
- case acc {
- [CoordItem(coords, Number(num)), ..rest] -> {
- let assert Ok(num) = int.digits(num, 10)
- let assert Ok(thing) = int.undigits(list.append(num, [n]), 10)
- [
- CoordItem([#(x_coord, y_coord), ..coords], Number(thing)),
- ..rest
- ]
- }
- _ -> [CoordItem([#(x_coord, y_coord)], Number(n)), ..acc]
- }
- }
- }
- }
- }
-}
-
-fn parse_grid(input: String) -> List(CoordItem) {
- let lines = string.split(input, "\n")
- list.index_fold(
- lines,
- [],
- fn(acc, line, x_coord) {
- let row =
- list.index_fold(
- string.to_graphemes(line),
- [],
- fn(acc, char, y_coord) {
- case char {
- "." -> [CoordItem([#(x_coord, y_coord)], Period), ..acc]
- x -> {
- case int.parse(x) {
- Error(_) -> [
- CoordItem([#(x_coord, y_coord)], Symbol(x)),
- ..acc
- ]
- Ok(n) -> {
- case acc {
- [CoordItem(coords, Number(num)), ..rest] -> {
- let assert Ok(num) = int.digits(num, 10)
- let assert Ok(thing) =
- int.undigits(list.append(num, [n]), 10)
- [
- CoordItem(
- [#(x_coord, y_coord), ..coords],
- Number(thing),
- ),
- ..rest
- ]
- }
- _ -> [CoordItem([#(x_coord, y_coord)], Number(n)), ..acc]
- }
- }
- }
- }
- }
- },
- )
- [row, ..acc]
- },
- )
- |> list.flatten
-}