aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J <thechairman@thechairman.info>2024-06-03 10:36:31 -0400
committerH.J <thechairman@thechairman.info>2024-06-03 10:36:31 -0400
commit7d704786ec158349f2f34590a858df6e78e844d6 (patch)
tree2a5b0f0af3bc2c322e941d25e2da9f9e66a6cdd3
parent9f0484222417d6b1495636123ae7de278b9fd0e5 (diff)
downloadgleam_aoc-7d704786ec158349f2f34590a858df6e78e844d6.tar.gz
gleam_aoc-7d704786ec158349f2f34590a858df6e78e844d6.zip
gleam day 1 2017
-rw-r--r--aoc2017-gleam/.github/workflows/test.yml23
-rw-r--r--aoc2017-gleam/.gitignore (renamed from aoc2019_gleam/.gitignore)0
-rw-r--r--aoc2017-gleam/README.md25
-rw-r--r--aoc2017-gleam/gleam.toml20
-rw-r--r--aoc2017-gleam/manifest.toml31
-rw-r--r--aoc2017-gleam/src/aoc2017_gleam.gleam5
-rw-r--r--aoc2017-gleam/src/aoc_2017/day_1.gleam32
-rw-r--r--aoc2017-gleam/test/aoc2017_gleam_test.gleam (renamed from aoc2019_gleam/test/aoc2019_gleam_test.gleam)0
-rw-r--r--aoc2019-gleam/.github/workflows/test.yml (renamed from aoc2019_gleam/.github/workflows/test.yml)0
-rw-r--r--aoc2019-gleam/.gitignore4
-rw-r--r--aoc2019-gleam/README.md (renamed from aoc2019_gleam/README.md)0
-rw-r--r--aoc2019-gleam/gleam.toml (renamed from aoc2019_gleam/gleam.toml)0
-rw-r--r--aoc2019-gleam/manifest.toml (renamed from aoc2019_gleam/manifest.toml)0
-rw-r--r--aoc2019-gleam/src/aoc2019_gleam.gleam (renamed from aoc2019_gleam/src/aoc2019_gleam.gleam)0
-rw-r--r--aoc2019-gleam/src/aoc_2019/day_1.gleam (renamed from aoc2019_gleam/src/aoc_2019/day_1.gleam)0
-rw-r--r--aoc2019-gleam/src/aoc_2019/day_2.gleam (renamed from aoc2019_gleam/src/aoc_2019/day_2.gleam)0
-rw-r--r--aoc2019-gleam/test/aoc2019_gleam_test.gleam12
17 files changed, 152 insertions, 0 deletions
diff --git a/aoc2017-gleam/.github/workflows/test.yml b/aoc2017-gleam/.github/workflows/test.yml
new file mode 100644
index 0000000..664c44a
--- /dev/null
+++ b/aoc2017-gleam/.github/workflows/test.yml
@@ -0,0 +1,23 @@
+name: test
+
+on:
+ push:
+ branches:
+ - master
+ - main
+ pull_request:
+
+jobs:
+ test:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: erlef/setup-beam@v1
+ with:
+ otp-version: "26.0.2"
+ gleam-version: "1.2.0-rc1"
+ rebar3-version: "3"
+ # elixir-version: "1.15.4"
+ - run: gleam deps download
+ - run: gleam test
+ - run: gleam format --check src test
diff --git a/aoc2019_gleam/.gitignore b/aoc2017-gleam/.gitignore
index 599be4e..599be4e 100644
--- a/aoc2019_gleam/.gitignore
+++ b/aoc2017-gleam/.gitignore
diff --git a/aoc2017-gleam/README.md b/aoc2017-gleam/README.md
new file mode 100644
index 0000000..9714473
--- /dev/null
+++ b/aoc2017-gleam/README.md
@@ -0,0 +1,25 @@
+# aoc2017_gleam
+
+[![Package Version](https://img.shields.io/hexpm/v/aoc2017_gleam)](https://hex.pm/packages/aoc2017_gleam)
+[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/aoc2017_gleam/)
+
+```sh
+gleam add aoc2017_gleam
+```
+```gleam
+import aoc2017_gleam
+
+pub fn main() {
+ // TODO: An example of the project in use
+}
+```
+
+Further documentation can be found at <https://hexdocs.pm/aoc2017_gleam>.
+
+## Development
+
+```sh
+gleam run # Run the project
+gleam test # Run the tests
+gleam shell # Run an Erlang shell
+```
diff --git a/aoc2017-gleam/gleam.toml b/aoc2017-gleam/gleam.toml
new file mode 100644
index 0000000..2be991f
--- /dev/null
+++ b/aoc2017-gleam/gleam.toml
@@ -0,0 +1,20 @@
+name = "aoc2017_gleam"
+version = "1.0.0"
+
+# Fill out these fields if you intend to generate HTML documentation or publish
+# your project to the Hex package manager.
+#
+# description = ""
+# licences = ["Apache-2.0"]
+# repository = { type = "github", user = "username", repo = "project" }
+# links = [{ title = "Website", href = "https://gleam.run" }]
+#
+# For a full reference of all the available options, you can have a look at
+# https://gleam.run/writing-gleam/gleam-toml/.
+
+[dependencies]
+gleam_stdlib = ">= 0.34.0 and < 2.0.0"
+gladvent = ">= 0.7.3 and < 1.0.0"
+
+[dev-dependencies]
+gleeunit = ">= 1.0.0 and < 2.0.0"
diff --git a/aoc2017-gleam/manifest.toml b/aoc2017-gleam/manifest.toml
new file mode 100644
index 0000000..d41f27a
--- /dev/null
+++ b/aoc2017-gleam/manifest.toml
@@ -0,0 +1,31 @@
+# This file was generated by Gleam
+# You typically do not need to edit this file
+
+packages = [
+ { name = "argv", version = "1.0.2", build_tools = ["gleam"], requirements = [], otp_app = "argv", source = "hex", outer_checksum = "BA1FF0929525DEBA1CE67256E5ADF77A7CDDFE729E3E3F57A5BDCAA031DED09D" },
+ { name = "filepath", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "EFB6FF65C98B2A16378ABC3EE2B14124168C0CE5201553DE652E2644DCFDB594" },
+ { name = "gladvent", version = "0.7.3", build_tools = ["gleam"], requirements = ["argv", "filepath", "gleam_erlang", "gleam_json", "gleam_otp", "gleam_package_interface", "gleam_stdlib", "glint", "parallel_map", "shellout", "simplifile", "snag", "spinner", "tom"], otp_app = "gladvent", source = "hex", outer_checksum = "59D93FD759427BCE8EE9828C0B62A3CD18362225F948C9789D334DCEAD621358" },
+ { name = "gleam_community_ansi", version = "1.4.0", build_tools = ["gleam"], requirements = ["gleam_community_colour", "gleam_stdlib"], otp_app = "gleam_community_ansi", source = "hex", outer_checksum = "FE79E08BF97009729259B6357EC058315B6FBB916FAD1C2FF9355115FEB0D3A4" },
+ { name = "gleam_community_colour", version = "1.4.0", build_tools = ["gleam"], requirements = ["gleam_json", "gleam_stdlib"], otp_app = "gleam_community_colour", source = "hex", outer_checksum = "795964217EBEDB3DA656F5EB8F67D7AD22872EB95182042D3E7AFEF32D3FD2FE" },
+ { name = "gleam_erlang", version = "0.25.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "054D571A7092D2A9727B3E5D183B7507DAB0DA41556EC9133606F09C15497373" },
+ { name = "gleam_json", version = "1.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib", "thoas"], otp_app = "gleam_json", source = "hex", outer_checksum = "9063D14D25406326C0255BDA0021541E797D8A7A12573D849462CAFED459F6EB" },
+ { name = "gleam_otp", version = "0.10.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "gleam_otp", source = "hex", outer_checksum = "0B04FE915ACECE539B317F9652CAADBBC0F000184D586AAAF2D94C100945D72B" },
+ { name = "gleam_package_interface", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_json", "gleam_stdlib"], otp_app = "gleam_package_interface", source = "hex", outer_checksum = "52A721BCA972C8099BB881195D821AAA64B9F2655BECC102165D5A1097731F01" },
+ { name = "gleam_stdlib", version = "0.38.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "663CF11861179AF415A625307447775C09404E752FF99A24E2057C835319F1BE" },
+ { name = "glearray", version = "0.2.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "glearray", source = "hex", outer_checksum = "9C207E05F38D724F464FA921378DB3ABC2B0A2F5821116D8BC8B2CACC68930D5" },
+ { name = "gleeunit", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "72CDC3D3F719478F26C4E2C5FED3E657AC81EC14A47D2D2DEBB8693CA3220C3B" },
+ { name = "glint", version = "1.0.0-rc2", build_tools = ["gleam"], requirements = ["gleam_community_ansi", "gleam_community_colour", "gleam_stdlib", "snag"], otp_app = "glint", source = "hex", outer_checksum = "FD5C47CE237CA67121F3946ADE7C630750BB67F5E8A4717D2DF5B5EE758CCFDB" },
+ { name = "parallel_map", version = "2.0.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_otp", "gleam_stdlib"], otp_app = "parallel_map", source = "hex", outer_checksum = "653714A9FD63EACD1A9D0A6582A972B0EC109AE275CDDD2E99CFC3DFAFAB9225" },
+ { name = "repeatedly", version = "2.1.1", build_tools = ["gleam"], requirements = [], otp_app = "repeatedly", source = "hex", outer_checksum = "38808C3EC382B0CD981336D5879C24ECB37FCB9C1D1BD128F7A80B0F74404D79" },
+ { name = "shellout", version = "1.6.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "shellout", source = "hex", outer_checksum = "E2FCD18957F0E9F67E1F497FC9FF57393392F8A9BAEAEA4779541DE7A68DD7E0" },
+ { name = "simplifile", version = "1.7.0", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "1D5DFA3A2F9319EC85825F6ED88B8E449F381B0D55A62F5E61424E748E7DDEB0" },
+ { name = "snag", version = "0.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "snag", source = "hex", outer_checksum = "54D32E16E33655346AA3E66CBA7E191DE0A8793D2C05284E3EFB90AD2CE92BCC" },
+ { name = "spinner", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_community_ansi", "gleam_erlang", "gleam_stdlib", "glearray", "repeatedly"], otp_app = "spinner", source = "hex", outer_checksum = "200BA3D4A04D468898E63C0D316E23F526E02514BC46454091975CB5BAE41E8F" },
+ { name = "thoas", version = "1.2.1", build_tools = ["rebar3"], requirements = [], otp_app = "thoas", source = "hex", outer_checksum = "E38697EDFFD6E91BD12CEA41B155115282630075C2A727E7A6B2947F5408B86A" },
+ { name = "tom", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "tom", source = "hex", outer_checksum = "A5364613E3DBF77F38EFF81DA9F99324086D029EC2B2D44348762FBE38602311" },
+]
+
+[requirements]
+gladvent = { version = ">= 0.7.3 and < 1.0.0"}
+gleam_stdlib = { version = ">= 0.34.0 and < 2.0.0" }
+gleeunit = { version = ">= 1.0.0 and < 2.0.0" }
diff --git a/aoc2017-gleam/src/aoc2017_gleam.gleam b/aoc2017-gleam/src/aoc2017_gleam.gleam
new file mode 100644
index 0000000..8c2ba67
--- /dev/null
+++ b/aoc2017-gleam/src/aoc2017_gleam.gleam
@@ -0,0 +1,5 @@
+import gleam/io
+
+pub fn main() {
+ io.println("Hello from aoc2017_gleam!")
+}
diff --git a/aoc2017-gleam/src/aoc_2017/day_1.gleam b/aoc2017-gleam/src/aoc_2017/day_1.gleam
new file mode 100644
index 0000000..786d0dd
--- /dev/null
+++ b/aoc2017-gleam/src/aoc_2017/day_1.gleam
@@ -0,0 +1,32 @@
+import gleam/int
+import gleam/list
+import gleam/result
+import gleam/string
+
+pub fn parse(input: String) {
+ input
+ |> string.to_graphemes()
+ |> list.map(int.parse)
+ |> result.values()
+}
+
+pub fn pt_1(input: List(Int)) {
+ pair_by(numbers: input, considering: 1)
+}
+
+pub fn pt_2(input: List(Int)) {
+ pair_by(numbers: input, considering: list.length(input) / 2)
+}
+
+fn find_neighbor_matches(number_pairs: List(#(Int, Int))) {
+ case number_pairs {
+ [] -> 0
+ [#(a, b), ..rest] if a == b -> a + find_neighbor_matches(rest)
+ [_, ..rest] -> find_neighbor_matches(rest)
+ }
+}
+
+fn pair_by(numbers xs: List(Int), considering by: Int) {
+ list.zip(xs, list.append(list.drop(xs, by), list.take(xs, by)))
+ |> find_neighbor_matches()
+}
diff --git a/aoc2019_gleam/test/aoc2019_gleam_test.gleam b/aoc2017-gleam/test/aoc2017_gleam_test.gleam
index 3831e7a..3831e7a 100644
--- a/aoc2019_gleam/test/aoc2019_gleam_test.gleam
+++ b/aoc2017-gleam/test/aoc2017_gleam_test.gleam
diff --git a/aoc2019_gleam/.github/workflows/test.yml b/aoc2019-gleam/.github/workflows/test.yml
index dd5e246..dd5e246 100644
--- a/aoc2019_gleam/.github/workflows/test.yml
+++ b/aoc2019-gleam/.github/workflows/test.yml
diff --git a/aoc2019-gleam/.gitignore b/aoc2019-gleam/.gitignore
new file mode 100644
index 0000000..599be4e
--- /dev/null
+++ b/aoc2019-gleam/.gitignore
@@ -0,0 +1,4 @@
+*.beam
+*.ez
+/build
+erl_crash.dump
diff --git a/aoc2019_gleam/README.md b/aoc2019-gleam/README.md
index bbf8121..bbf8121 100644
--- a/aoc2019_gleam/README.md
+++ b/aoc2019-gleam/README.md
diff --git a/aoc2019_gleam/gleam.toml b/aoc2019-gleam/gleam.toml
index c9ede3d..c9ede3d 100644
--- a/aoc2019_gleam/gleam.toml
+++ b/aoc2019-gleam/gleam.toml
diff --git a/aoc2019_gleam/manifest.toml b/aoc2019-gleam/manifest.toml
index 12fa60f..12fa60f 100644
--- a/aoc2019_gleam/manifest.toml
+++ b/aoc2019-gleam/manifest.toml
diff --git a/aoc2019_gleam/src/aoc2019_gleam.gleam b/aoc2019-gleam/src/aoc2019_gleam.gleam
index c5a7e0a..c5a7e0a 100644
--- a/aoc2019_gleam/src/aoc2019_gleam.gleam
+++ b/aoc2019-gleam/src/aoc2019_gleam.gleam
diff --git a/aoc2019_gleam/src/aoc_2019/day_1.gleam b/aoc2019-gleam/src/aoc_2019/day_1.gleam
index 8a7fd2d..8a7fd2d 100644
--- a/aoc2019_gleam/src/aoc_2019/day_1.gleam
+++ b/aoc2019-gleam/src/aoc_2019/day_1.gleam
diff --git a/aoc2019_gleam/src/aoc_2019/day_2.gleam b/aoc2019-gleam/src/aoc_2019/day_2.gleam
index 8faa0ea..8faa0ea 100644
--- a/aoc2019_gleam/src/aoc_2019/day_2.gleam
+++ b/aoc2019-gleam/src/aoc_2019/day_2.gleam
diff --git a/aoc2019-gleam/test/aoc2019_gleam_test.gleam b/aoc2019-gleam/test/aoc2019_gleam_test.gleam
new file mode 100644
index 0000000..3831e7a
--- /dev/null
+++ b/aoc2019-gleam/test/aoc2019_gleam_test.gleam
@@ -0,0 +1,12 @@
+import gleeunit
+import gleeunit/should
+
+pub fn main() {
+ gleeunit.main()
+}
+
+// gleeunit test functions end in `_test`
+pub fn hello_world_test() {
+ 1
+ |> should.equal(1)
+}