diff options
Diffstat (limited to 'codingquest2024')
-rw-r--r-- | codingquest2024/.github/workflows/test.yml | 23 | ||||
-rw-r--r-- | codingquest2024/.gitignore | 5 | ||||
-rw-r--r-- | codingquest2024/README.md | 25 | ||||
-rw-r--r-- | codingquest2024/gleam.toml | 22 | ||||
-rw-r--r-- | codingquest2024/manifest.toml | 17 | ||||
-rw-r--r-- | codingquest2024/src/codingquest2024.gleam | 5 | ||||
-rw-r--r-- | codingquest2024/src/day1/solution.gleam | 55 | ||||
-rw-r--r-- | codingquest2024/src/day2/solution.gleam | 66 | ||||
-rw-r--r-- | codingquest2024/src/day3/solution.gleam | 50 | ||||
-rw-r--r-- | codingquest2024/src/day4/solution.gleam | 49 | ||||
-rw-r--r-- | codingquest2024/src/day5/solution.gleam | 67 | ||||
-rw-r--r-- | codingquest2024/src/day6/solution.gleam | 86 | ||||
-rw-r--r-- | codingquest2024/src/day7/solution.gleam | 73 | ||||
-rw-r--r-- | codingquest2024/src/day8/solution.gleam | 26 | ||||
-rw-r--r-- | codingquest2024/src/day9/input.txt | 203 | ||||
-rw-r--r-- | codingquest2024/src/day9/solution.gleam | 0 | ||||
-rw-r--r-- | codingquest2024/src/utilities/memo.gleam | 57 | ||||
-rw-r--r-- | codingquest2024/test/codingquest2024_test.gleam | 12 |
18 files changed, 0 insertions, 841 deletions
diff --git a/codingquest2024/.github/workflows/test.yml b/codingquest2024/.github/workflows/test.yml deleted file mode 100644 index 916edea..0000000 --- a/codingquest2024/.github/workflows/test.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: test - -on: - push: - branches: - - master - - main - pull_request: - -jobs: - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: erlef/setup-beam@v1 - with: - otp-version: "26.0.2" - gleam-version: "1.0.0" - rebar3-version: "3" - # elixir-version: "1.15.4" - - run: gleam deps download - - run: gleam test - - run: gleam format --check src test diff --git a/codingquest2024/.gitignore b/codingquest2024/.gitignore deleted file mode 100644 index 6fdd6db..0000000 --- a/codingquest2024/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -*.beam -*.ez -/build -erl_crash.dump -data.txt diff --git a/codingquest2024/README.md b/codingquest2024/README.md deleted file mode 100644 index 8412b48..0000000 --- a/codingquest2024/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# codingquest2024 - -[](https://hex.pm/packages/codingquest2024) -[](https://hexdocs.pm/codingquest2024/) - -```sh -gleam add codingquest2024 -``` -```gleam -import codingquest2024 - -pub fn main() { - // TODO: An example of the project in use -} -``` - -Further documentation can be found at <https://hexdocs.pm/codingquest2024>. - -## Development - -```sh -gleam run # Run the project -gleam test # Run the tests -gleam shell # Run an Erlang shell -``` diff --git a/codingquest2024/gleam.toml b/codingquest2024/gleam.toml deleted file mode 100644 index f39baa5..0000000 --- a/codingquest2024/gleam.toml +++ /dev/null @@ -1,22 +0,0 @@ -name = "codingquest2024" -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 or ~> 1.0" -simplifile = "~> 1.5" -gleam_otp = "~> 0.10" -gleam_erlang = "~> 0.24" - -[dev-dependencies] -gleeunit = "~> 1.0" diff --git a/codingquest2024/manifest.toml b/codingquest2024/manifest.toml deleted file mode 100644 index 55b1f61..0000000 --- a/codingquest2024/manifest.toml +++ /dev/null @@ -1,17 +0,0 @@ -# This file was generated by Gleam -# You typically do not need to edit this file - -packages = [ - { name = "gleam_erlang", version = "0.24.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "26BDB52E61889F56A291CB34167315780EE4AA20961917314446542C90D1C1A0" }, - { 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_stdlib", version = "0.36.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "C0D14D807FEC6F8A08A7C9EF8DFDE6AE5C10E40E21325B2B29365965D82EB3D4" }, - { name = "gleeunit", version = "1.0.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "D364C87AFEB26BDB4FB8A5ABDE67D635DC9FA52D6AB68416044C35B096C6882D" }, - { name = "simplifile", version = "1.5.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "EB9AA8E65E5C1E3E0FDCFC81BC363FD433CB122D7D062750FFDF24DE4AC40116" }, -] - -[requirements] -gleam_erlang = { version = "~> 0.24"} -gleam_otp = { version = "~> 0.10" } -gleam_stdlib = { version = "~> 0.34 or ~> 1.0" } -gleeunit = { version = "~> 1.0" } -simplifile = { version = "~> 1.5" } diff --git a/codingquest2024/src/codingquest2024.gleam b/codingquest2024/src/codingquest2024.gleam deleted file mode 100644 index 5af4a2a..0000000 --- a/codingquest2024/src/codingquest2024.gleam +++ /dev/null @@ -1,5 +0,0 @@ -import gleam/io - -pub fn main() { - io.println("Hello from codingquest2024!") -} diff --git a/codingquest2024/src/day1/solution.gleam b/codingquest2024/src/day1/solution.gleam deleted file mode 100644 index abef2eb..0000000 --- a/codingquest2024/src/day1/solution.gleam +++ /dev/null @@ -1,55 +0,0 @@ -import gleam/dict.{type Dict} -import gleam/int -import gleam/io -import gleam/list -import gleam/option.{None, Some} -import gleam/regex -import gleam/result -import gleam/string -import simplifile - -pub type Adjustment { - Adjustment(spaceliner: String, value: Int) -} - -pub fn main() { - let assert Ok(data) = simplifile.read(from: "./src/day1/data.txt") - - let raw_adjustments = string.split(data, "\n") - - raw_adjustments - |> collate_adjustments - |> dict.values - |> list.reduce(with: int.min) - |> result.unwrap(0) - |> int.to_string() - |> io.println() -} - -fn parse_line(line: String) -> Adjustment { - let assert Ok(re) = regex.from_string("[\\s:]+") - - let assert [spaceliner, kind, raw_value] = - regex.split(with: re, content: line) - - let assert Ok(value) = int.parse(raw_value) - Adjustment(spaceliner, classify_adjustment(kind) * value) -} - -fn classify_adjustment(name: String) -> Int { - case name { - "Seat" | "Meals" | "Luggage" | "Fee" | "Tax" -> 1 - "Discount" | "Rebate" -> -1 - _ -> panic as "unknown adjustment kind" - } -} - -fn collate_adjustments(raw_adjustments: List(String)) -> Dict(String, Int) { - use acc, this <- list.fold(over: raw_adjustments, from: dict.new()) - let adjustment = parse_line(this) - use maybe_v <- dict.update(in: acc, update: adjustment.spaceliner) - case maybe_v { - None -> adjustment.value - Some(v) -> v + adjustment.value - } -} diff --git a/codingquest2024/src/day2/solution.gleam b/codingquest2024/src/day2/solution.gleam deleted file mode 100644 index 59f8d29..0000000 --- a/codingquest2024/src/day2/solution.gleam +++ /dev/null @@ -1,66 +0,0 @@ -import gleam/bit_array -import gleam/list -import gleam/int -import gleam/io -import gleam/string -import simplifile - -pub type Location { - Internal - Passenger - Other -} - -pub type Packet { - Packet(length: Int, endpoint: Location) -} - -pub fn main() { - let assert Ok(data) = simplifile.read(from: "./src/day2/data.txt") - - let #(internal_packets, passenger_packets) = - data - |> string.split("\n") - |> list.map(parse_packet) - |> list.partition(fn(p) { p.endpoint == Internal }) - - { - int.to_string(sum_packet_lengths(internal_packets)) - <> "/" - <> int.to_string(sum_packet_lengths(passenger_packets)) - } - |> io.println() -} - -fn parse_packet(raw_packet: String) { - let assert Ok(<< - _:bytes-size(2), - length:int-size(16), - _:bytes-size(8), - source:bytes-size(4), - destination:bytes-size(4), - >>) = bit_array.base16_decode(raw_packet) - - Packet(length, set_endpoint(source, destination)) -} - -fn set_endpoint(source: BitArray, dest: BitArray) -> Location { - case identify_location(source), identify_location(dest) { - Other, Internal | Internal, Other -> Internal - Other, Passenger | Passenger, Other -> Passenger - _, _ -> Other - } -} - -fn identify_location(ip: BitArray) -> Location { - case ip { - <<192, 168, _, _>> -> Internal - <<10, 0, _, _>> -> Passenger - _ -> Other - } -} - -fn sum_packet_lengths(packets: List(Packet)) -> Int { - use acc, p <- list.fold(packets, 0) - acc + p.length -} diff --git a/codingquest2024/src/day3/solution.gleam b/codingquest2024/src/day3/solution.gleam deleted file mode 100644 index 6314060..0000000 --- a/codingquest2024/src/day3/solution.gleam +++ /dev/null @@ -1,50 +0,0 @@ -import gleam/bit_array -import gleam/int -import gleam/io -import gleam/string -import gleam/string_builder.{type StringBuilder} -import simplifile - -pub fn main() { - let assert Ok(data) = simplifile.read(from: "./src/day3/data.txt") - - data - |> string.split(" ") - |> build_flat_image(" ", string_builder.new()) - |> bit_array.from_string() - |> print_next_slice() -} - -fn build_flat_image( - nums: List(String), - pixel: String, - acc: StringBuilder, -) -> String { - case nums { - [] -> string_builder.to_string(acc) - [h, ..t] -> { - let assert Ok(n) = int.parse(h) - let pixels = string.repeat(pixel, n) - build_flat_image(t, next_pixel(pixel), string_builder.append(acc, pixels)) - } - } -} - -fn print_next_slice(str: BitArray) -> Nil { - case str { - <<slice:bytes-size(100), rest:bytes>> -> { - let assert Ok(out) = bit_array.to_string(slice) - io.println(out) - print_next_slice(rest) - } - _ -> Nil - } -} - -fn next_pixel(p: String) -> String { - case p { - " " -> "#" - "#" -> " " - _ -> panic - } -} diff --git a/codingquest2024/src/day4/solution.gleam b/codingquest2024/src/day4/solution.gleam deleted file mode 100644 index a03b2be..0000000 --- a/codingquest2024/src/day4/solution.gleam +++ /dev/null @@ -1,49 +0,0 @@ -import gleam/float -import gleam/io -import gleam/list -import gleam/regex -import gleam/result -import gleam/string -import simplifile - -pub type Star { - Star(name: String, x: Float, y: Float, z: Float) -} - -pub fn main() { - let assert Ok(data) = simplifile.read(from: "./src/day4/data.txt") - - let assert [_, ..stars] = string.split(data, "\n") - - stars - |> list.map(parse_star_record) - |> list.combination_pairs() - |> list.map(star_distance) - |> list.reduce(float.min) - |> io.debug -} - -fn parse_star_record(str: String) -> Star { - let assert Ok(re) = regex.from_string("\\s{2,}") - - let assert [name, ..coords] = regex.split(with: re, content: str) - let assert [_, x, y, z] = - coords - |> list.map(float.parse) - |> result.values - - Star(name, x, y, z) -} - -fn star_distance(stars: #(Star, Star)) -> Float { - let #(star1, star2) = stars - let assert Ok(dist) = - float.square_root( - sq(star1.x -. star2.x) +. sq(star1.y -. star2.y) +. sq(star1.z -. star2.z), - ) - dist -} - -fn sq(x: Float) -> Float { - x *. x -} diff --git a/codingquest2024/src/day5/solution.gleam b/codingquest2024/src/day5/solution.gleam deleted file mode 100644 index 6c10693..0000000 --- a/codingquest2024/src/day5/solution.gleam +++ /dev/null @@ -1,67 +0,0 @@ -import gleam/dict.{type Dict} -import gleam/io -import gleam/int -import gleam/list -import gleam/regex -import gleam/result -import gleam/string -import simplifile - -type Atlas = - Dict(String, Dict(String, Int)) - -pub fn main() { - let assert Ok(data) = simplifile.read(from: "./src/day5/data.txt") - - let assert [table, routes] = string.split(data, "\n\n") - let assert [header, ..rows] = string.split(table, "\n") - - let dests = - header - |> string.trim() - |> split_on_many_spaces - - let atlas = build_atlas(rows, dests) - - routes - |> string.split("\n") - |> list.fold(0, fn(acc, route) { acc + find_total_distance(route, atlas) }) - |> io.debug -} - -fn split_on_many_spaces(str) { - let assert Ok(re_spaces) = regex.from_string("\\s+") - regex.split(re_spaces, str) -} - -fn build_atlas(rows, dests) { - rows - |> list.map(split_on_many_spaces) - |> list.fold(dict.new(), fn(acc, row) { - let assert [from, ..raw_dists] = row - let assert Ok(dists) = list.try_map(raw_dists, int.parse) - let to_dict = - dests - |> list.zip(dists) - |> dict.from_list() - - dict.insert(acc, from, to_dict) - }) -} - -fn dist_between(leg: #(String, String), dict: Atlas) -> Int { - let assert Ok(dist) = - dict - |> dict.get(leg.0) - |> result.try(dict.get(_, leg.1)) - - dist -} - -fn find_total_distance(row: String, atlas: Atlas) { - let assert [_, route] = string.split(row, ": ") - - string.split(route, " -> ") - |> list.window_by_2 - |> list.fold(0, fn(acc, leg) { acc + dist_between(leg, atlas) }) -} diff --git a/codingquest2024/src/day6/solution.gleam b/codingquest2024/src/day6/solution.gleam deleted file mode 100644 index 8a0319c..0000000 --- a/codingquest2024/src/day6/solution.gleam +++ /dev/null @@ -1,86 +0,0 @@ -import gleam/dict -import gleam/io -import gleam/list -import gleam/regex -import gleam/result -import gleam/string -import simplifile - -pub opaque type Location { - Location(row: Int, col: Int) -} - -pub fn main() { - let assert Ok(data) = simplifile.read(from: "./src/day6/data.txt") - let assert ["Cipher key: " <> key, "Message: " <> raw_message] = - string.split(data, "\n") - - let letter_to_location = make_cipher_grid(key) - let location_to_letter = - letter_to_location - |> dict.fold(dict.new(), fn(acc, k, v) { dict.insert(acc, v, k) }) - - raw_message - |> string.split(" ") - |> list.map(fn(s) { - s - |> string.to_graphemes - |> list.sized_chunk(2) - }) - |> list.map(fn(s) { - s - |> decode_word(letter_to_location, location_to_letter) - |> string.concat() - }) - |> string.join(" ") - |> io.println() -} - -fn make_cipher_grid(key) { - let assert Ok(in_key) = regex.from_string("[" <> key <> "]") - let grid = - regex.split(in_key, "abcdefghiklmnopqrstuvwxyz") - |> string.concat - |> string.append(key, _) - |> string.to_graphemes - |> list.sized_chunk(5) - - list.index_map(grid, fn(row, r) { - list.index_map(row, fn(cell, c) { #(cell, Location(r, c)) }) - }) - |> list.flatten - |> dict.from_list -} - -fn decode_word(word: List(List(String)), to_loc, to_letter) { - case word { - [] -> [] - [[a, b], ..rest] -> [ - transform_pair(a, b, to_loc, to_letter), - ..decode_word(rest, to_loc, to_letter) - ] - _ -> panic as "bad playfair format" - } -} - -fn transform_pair(a, b, to_loc, to_letter) { - let assert Ok(Location(r_a, c_a)) = dict.get(to_loc, a) - let assert Ok(Location(r_b, c_b)) = dict.get(to_loc, b) - - case r_a == r_b, c_a == c_b { - True, _ -> [ - dict.get(to_letter, Location(r_a, { c_a + 4 } % 5)), - dict.get(to_letter, Location(r_b, { c_b + 4 } % 5)), - ] - _, True -> [ - dict.get(to_letter, Location({ r_a + 4 } % 5, c_a)), - dict.get(to_letter, Location({ r_b + 4 } % 5, c_b)), - ] - _, _ -> [ - dict.get(to_letter, Location(r_a, c_b)), - dict.get(to_letter, Location(r_b, c_a)), - ] - } - |> result.values - |> string.concat -} diff --git a/codingquest2024/src/day7/solution.gleam b/codingquest2024/src/day7/solution.gleam deleted file mode 100644 index 2ca7cbf..0000000 --- a/codingquest2024/src/day7/solution.gleam +++ /dev/null @@ -1,73 +0,0 @@ -import gleam/io -import gleam/string -import gleam/set.{type Set} -import gleam/int -import gleam/regex.{Match} -import gleam/option.{Some} -import simplifile - -pub opaque type Item { - File(name: String, size: Int) - Directory(name: String) -} - -pub fn main() { - let assert Ok(data) = simplifile.read(from: "./src/day7/data.txt") - let lines = string.split(data, "\n") - - mark_for_deletion(lines, 0, "", set.new()) - |> io.debug() -} - -fn mark_for_deletion( - lines: List(String), - deleted: Int, - current_folder: String, - deleted_folders: Set(String), -) { - case lines { - [] -> deleted - ["Folder: " <> folder, ..rest] -> - mark_for_deletion(rest, deleted, folder, deleted_folders) - [file, ..rest] -> { - case - string.contains(file, "temporary") - || string.contains(file, "delete") - || set.contains(deleted_folders, current_folder) - { - True -> - case string.contains(file, "[FOLDER") { - True -> { - file - |> get_folder_number() - |> set.insert(deleted_folders, _) - |> mark_for_deletion(rest, deleted, current_folder, _) - } - False -> { - file - |> get_file_size() - |> int.add(deleted, _) - |> mark_for_deletion(rest, _, current_folder, deleted_folders) - } - } - False -> - mark_for_deletion(rest, deleted, current_folder, deleted_folders) - } - } - } -} - -fn get_folder_number(file) { - let assert Ok(re) = regex.from_string("\\[FOLDER ([0-9]+)\\]") - - let assert [Match(submatches: [Some(n)], ..)] = regex.scan(re, file) - n -} - -fn get_file_size(file) { - let assert Ok(re) = regex.from_string("- .+ ([0-9]+)$") - - let assert [Match(submatches: [Some(n)], ..)] = regex.scan(re, file) - let assert Ok(n) = int.parse(n) - n -} diff --git a/codingquest2024/src/day8/solution.gleam b/codingquest2024/src/day8/solution.gleam deleted file mode 100644 index cb4d907..0000000 --- a/codingquest2024/src/day8/solution.gleam +++ /dev/null @@ -1,26 +0,0 @@ -import gleam/io -import gleam/int -import gleam/list -import utilities/memo - -const options = [40, 12, 2, 1] - -const distance = 856 - -pub fn main() { - use cache <- memo.create() - solve(distance, cache) - |> io.debug -} - -fn solve(target, cache) { - use <- memo.memoize(cache, target) - case target { - 0 -> 1 - _ -> - options - |> list.filter(fn(n) { n <= target }) - |> list.map(fn(n) { solve(target - n, cache) }) - |> int.sum - } -} diff --git a/codingquest2024/src/day9/input.txt b/codingquest2024/src/day9/input.txt deleted file mode 100644 index 1d30914..0000000 --- a/codingquest2024/src/day9/input.txt +++ /dev/null @@ -1,203 +0,0 @@ -##################################################################################################### -......#.....#.#.......#.....#.....#.....#.#.................#...............#.............#.#.......# -#.###.#.#.#.#.#.#####.#.#.#.#.###.###.#.#.#.#######.#######.#########.#####.#.#####.#####.#.#.###.#.# -#.#.#...#.#.#.#.#...#...#.#...#.#.....#.#.#...#...#.#...#.....#.....#.#...#.#.#...#.#...#.#...#...#.# -#.#.#####.#.#.#.#.#.#####.#####.#######.#.###.#.#.#.#.#.#.###.#.###.#.#.#.#.#.#.#.#.#.#.#.#.###.##### -#...#$..#.$...#$#.#.$.#.#$..#.$....$..#.$....$#.#.$.#.#$..#.$.#.#$..#.$.#..$..#.$...#$#.#.$.#.#$#...# -###.#.#.#.#####.#.###.#.###.#.#######.#.###.###.#####.#####.###.#.###.###.###.#.#####.###.#.#.#.#.#.# -#.#...#.#.......#...#...#...#.......#.#...#...#...#...#...#.....#.#.....#.#...#.#.....#...#...#.#.#.# -#.#####.#########.#.#####.#.#########.###.#######.#.#.#.#.#######.###.#.###.###.#.#.#.#.#####.#.#.#.# -#.....#.#.#.......#...#...#.#...#...#...#...#.....#.#.#.#.#.....#...#.#...#.#.#.#.#.#.#.....#.#...#.# -#.###$#.#.$.###$####$.#.#$###.$.#.#$#.#.$##.#$####$.#.#$#.#.$.#.#$#.##$##.#$#.#.$##.#$####$.#.#$###.# -#...#...#.......#...#.#.......#.#.#.#.#...#.#.#.....#...#...#.#...#.#...#.....#.#...#.....#.#...#.#.# -###.#####.#####.#.#.#.#########.#.#.#.#.#.#.#.#########.#####.#####.#.#.#######.#.#.#.#.###.###.#.#.# -#.#.#.....#...#.#.#...#...#...#.#.#.#.#.#.#.#.#...#...#...#.#...#...#.#.......#.#.#.#.#...#...#...#.# -#.#.#.#####.#.###.###.#.#.#.#.#.#.#.###.###.#.#.#.#.#.###.#.###.#.###.#######.#.#.#.#.###.###.#####.# -#.#.#$#...$.#..$#.#.$.#.#$#.#.$.#.#$#...$...#$..#.$.#..$#.#.$.#..$#...$.#.#$..#.$.#.#$#.#.$...#$....# -#.#.#.#.#######.#.#.###.#.#.#####.#.#.#.#.#####.#######.#.#.#.#########.#.#.###.#.#.#.#.#.#.###.###.# -#.#.#.#...#...#.#.#.....#.#.#.....#.#.#.#.....#.#.#...#.#...#...........#.#.....#.#.#...#.#...#.#...# -#.#.#####.#.#.#.#.#########.#.#####.#.#.#####.#.#.#.#.#.#################.#######.#.###.#.###.#.###.# -#.#.#.....#.#.....#.......#...#.....#.#.....#.#.#...#.#...#...#...#...#.#.........#.#...#...#.#...#.# -#.#.#$####$.###$###.$####$####$.###$#.##$####$#.##$##.#$#.#.$.#.#$#.#.$.#.#$####$.###$####$.#.#$#.### -#.#.#.#...#.#.......#.#...#...#...#...........#.....#.#...#.#...#...#.#.......#.#.....#...#...#.#...# -#.#.#.###.#.#.#######.#.###.#.###.#######.#########.#.#.###.#########.#######.#.#######.#.#####.###.# -#.#.#...#...#.....#...#.....#...#.......#.#...#.......#.#...#.......#...#...#...#.......#...#.....#.# -#.#.#.#.#.#######.#.###########.###.###.#.#.#.#.#######.#.###.#.#######.#.#.###.#####.#####.#####.#.# -#...#$#.#.$...#$..#.$.#..$#...$...#$#.#.$...#$#...$...#$#...$.#..$....$.#.#$#...$...#$#...$...#$#.#.# -#.#####.###.#.#.###.#.#.#.#.#.###.#.#.#.#####.#####.#.#.###.#########.#.#.#.###.#.#.#.#.#####.#.#.#.# -#.#.....#...#...#...#...#...#...#.#...#.#...#.......#.#...#...#...#...#...#...#...#...#.......#...#.# -#.#.#.#.#.#######.#########.###.#.#####.#.###########.#.#.###.#.#.#.#########.#########.#######.###.# -#.#.#.#.#.......#.#...#...#...#.#.......#...........#.#.#...#.#.#...#.......#...#...#...#.........#.# -#.###$#.##$####$#.#.$.#.#$####$.###$####$.###$###.$##.#$###.$.#.#$###.$####$###.$.###$###.$####$###.# -#.....#.#.....#.#...#.#.#...#.......#...#.......#...#...#.#.#...#.#...#...#.....#...#.#.....#.......# -#######.###.#.#.#######.###.#.#####.#.#.###.#####.#.#####.#.###.###.###.#.#########.#.#.#####.#####.# -#.#.....#...#.#.#.......#.#.#...#.....#.#...#...#.#.#.....#.#...#...#...#...........#.#.#...#.#.#...# -#.#.#####.###.#.#.#######.#.###.#.#####.#####.#.###.#.#.###.#.###.###############.###.#.#.#.#.#.#.### -#.#.#$....$...#$#...$....$#.#.$.#.#$..#.$...#$#...$.#.#$..#.$.#.#$#...$....$....$....$#.#.$...#$..#.# -#.#.#.###.#.###.###.#######.#.#####.#.#####.#.#######.###.#.#.#.#.#.###########.#.#######.#####.###.# -#...#.#.#.#...#.....#.......#.......#.#.......#.....#...#...#.#.#.#.......#.#...#.#.....#...#.......# -#.###.#.#.###########.#####.#####.###.#####.###.###.###.#####.#.#.#######.#.#.###.#.###.#.#.#######.# -#.#.#.#.#.#...#.....#...#...#...#...#.....#.#...#.#...#.#...#.#.#.......#...#.#.....#...#.#.#.....#.# -#.#.#$#.#.$.#.#$###.$##.#$#.#.$.###$###.$.#.#$###.$.###$#.#.$.#.#$###.$####$#.##$####$###.$.#.#$#.#.# -#.#.....#.#.#.#.#...#.#...#.#.#...#...#.#.#.#.....#.#.....#.#...#...#.......#.#...#.#...#.#.#.#...#.# -#.#######.#.#.#.#.#.#.###.###.###.#.#.###.#.#####.#.#.#####.###.#.#.###.#####.#.#.#.###.###.#.#.###.# -#...#.....#.#...#.#...#.#.....#.#...#...#.#.#.....#...#...#...#.#.#...#.#...#.#.#.#...#...#...#.#...# -###.#.#####.#####.###.#.#######.#######.#.###.#########.#.#####.#.###.#.#.#.#.#.#.#.#.###.#.###.#.### -#.#.#$....$...#$..#.$.#..$..#.$....$..#.$.#..$#...$.#.#$#.#.$...#$..#.$.#.#$#...$.#.#$..#.$.#..$#.#.# -#.#.#.###.###.#.###.#.###.#.#.###.###.#.#.#.###.###.#.#.#.#.#######.#.###.#.#####.#.#####.#.#.###.#.# -#.#.#...#...#.#.#...#.....#.#.#...#...#.#...#...#...#.#.#...#.....#.#.....#.......#.......#.#.#.....# -#.#.#####.#.#.#.#.#########.#.#.#####.#.###.#.#####.#.#.#####.#####.###############.#########.#####.# -#.#.....#.#.#.#.#.......#...#.#.....#.#...#...#...#...#...#.....#...#.....................#...#...#.# -#.###$#.#.$##.#$###.$.###$###.$####$#.##$.###$#.#.$##.#$#.#.$##.#$###.$####$###.$####$###.$.#.#$#.#.# -#.....#.#.....#...#.#.#...#.#.#...#.#...#.......#...#...#.#.#...#.#.....#.....#...#.....#.#.#.#.#.#.# -#.#.###.#####.###.#.#.#.###.#.#.#.#.###.###########.###.#.###.###.#####.#.###.#####.###.#.#.###.#.### -#.#...#.#...#.#...#.#.#.#.....#.#.#...#...#...#...#...#.#...#...#.....#.#...#.........#.#...#...#...# -#.###.#.#.#.###.###.#.#.#####.#.#####.###.#.#.###.###.#.###.###.#####.###.###########.#.#####.#####.# -#.#.#$..#.$....$#...$.#.#$..#.$....$#...$...#$....$...#$..#.$.#..$#.#.$...#$....$...#$#.#.$...#$....# -#.#.#####.#######.###.#.#.#.#.#####.###.#########.#.#########.#.#.#.#######.#######.#.#.#.#####.###.# -#.#.....#.....#.#.#.#...#.#.#.#.....#.#.#.......#.#.#...#...#.#.#.......#...#.....#.#.#.....#...#.#.# -#.###.#.#####.#.#.#.#####.#.#.#.###.#.#.###.#####.#.#.#.#.#.#.#.#########.###.###.#.#########.###.#.# -#.....#.......#.#.......#.#.#...#.#.#.#...#.#.....#.#.#.#.#.#.#...#.......#...#...#...........#.#...# -#####$####$####$####$##.#$#.##$##.#$#.##$.#.#$####$.#.#$#.#.$.###$#.##$####$####$####$####$####$#.### -#.........#...#.......#...#.#.....#.....#.#.#.#...#...#...#...#...#...#.....#...................#.#.# -#.#.#####.#.#.#.#.#########.#.#.#####.###.#.#.#.#.###########.#.#####.#.#####.###.#############.#.#.# -#.#...#.#...#.#.#.#...#.....#.#.....#.#...#...#.#.......#...#...#.....#...#...#.#.....#...#...#.#...# -#####.#.#####.#.#.#.#.#.#########.#.#.#.#######.#######.#.#.#####.#######.#.###.#####.#.#.#.#.#####.# -#....$#.#.$.#..$#.#.$...#$....$...#$#.#.$....$..#.$....$#.#.$....$#...$...#$....$...#$..#.$.#..$..#.# -#.#####.#.#.#####.#.#####.###.#######.#.#.#######.#.#####.#########.#####.#####.#.#.#####.#.###.###.# -#.#.......#.....#.#.#...#.#.#.....#...#.#.#.......#.......#.............#...#...#.#.....#.#...#...#.# -#.###.#####.#####.#.###.#.#.#####.#.###.#.#.###.#.#########.###########.#####.#######.#.#.#.#####.#.# -#...#...#.#.......#...#.#...#...#.....#.#.#...#.#.....#...#.#.........#.#.....#.......#.#.#.#.....#.# -#.#.#$#.#.$####$####$.#.#$###.$.#.#$###.$.###$#.##$##.#$#.#.$.###$###.$.#.#$###.$####$#.#.$.#.#$#.#.# -#.#.#...#...........#.#...#...#.#...#...#.#...#.....#...#.#.#.......#.#...#.....#...#...#...#.#...#.# -#.#.#.###.#.#####.###.#.###.###.#####.#.#.#########.###.###.#######.###.###.###.#.#.#.#######.#.###.# -#.#.#.....#.#...#.#...#...#...#.#.....#.#.#.....#...#...#...#...#.#.#...#...#.#.#.#.#.....#...#.#...# -#.#.#########.#.###.#########.#.#.#####.#.#.###.#.#######.###.#.#.#.#.###.###.#.#.#.#######.#####.### -#.#..$#...$...#$....$....$#...$.#.#$..#.$...#$..#.$....$..#.$.#..$#.#.$.#..$#...$.#..$....$....$#...# -#####.#.#############.###.#.###.#.#.#.#.#####.###.#.#########.###.#.###.#.#.#.###.#######.#.###.###.# -#.....#.#...#.........#.#.#...#.#...#.#...#...#...#.....#.....#...#...#.#.#.#.#.#.#...#...#.#.....#.# -#.#.###.#.#.#.#########.#.#.#.#.#####.###.#.###.#######.#.###########.#.###.#.#.#.###.#.#####.#####.# -#.#.#.....#...#.........#.#.#.#.......#...#.#.........#.#...#.........#.....#...#...#.#.#.....#...#.# -#.###$####$####$####$##.#$###.$####$####$##.#$####$##.#$###.$.###$####$##.#$####$.#.#$#.#.$####$#.#.# -#.....#.......#.#.....#.#.....#.....#.......#.#.......#...#.#.....#.#.....#.....#.#.#...#.#...#.#...# -#######.#####.#.#.###.#####.#####.###.#######.#.#########.#.#####.#.#.#####.###.#.#.#.###.#.#.#.##### -#...#...#...#.#.#...#.......#...#.#...#.......#...........#.....#.#...#.....#.#.#.#.#...#.#.#.#...#.# -#.#.#.###.###.#.###.#########.#.###.#########.#############.#.#.#.#.###.#####.#.#.#.###.#.#.#.###.#.# -#.#..$#...$...#$#...$.#..$#...$...#$#...$...#$....$.#..$..#.$.#.#$#.#.$.#..$#...$.#.#$#.#.$.#..$..#.# -#.#####.#.#.###.#.#####.#.#.#####.#.#.#####.#######.#.###.###.#.#.###.###.#.#.#####.#.#.#.#.#######.# -#...#.#.#...#.....#.#...#.#.#...#.#...#.....#.......#...#.#...#.#...#.#...#.#.......#...#.#.#.....#.# -#.#.#.#.#########.#.#.###.#.#.#.#.#####.#####.#######.#.#.#.#######.#.#.###.###.#####.###.#.###.#.#.# -#.#.#.#.#.......#...#.#.#...#.#...#.....#...#.....#...#.#...#...#...#.....#...#.#...#.....#.....#.#.# -###.#$#.#.$####$####$.#.#$###.$####$####$.#.#$###.$.###$####$.#.#$###.$####$#.##$.#.#$####$####$#.#.# -#...#.....#.........#.#.#.....#...#.#.#...#...#...#...#.#.....#...#.#.#.....#.#...#.#.........#...#.# -#.#########.#######.#.#.#.#####.#.#.#.#.###.###.#######.#.#########.#.#.###.#.#.###.#.#####.#.#.###.# -#.......#...#.....#...#...#.....#...#.#.#.#.........#...#.....#.......#.#.#...#.#...#.#.#...#.#.#...# -#.#####.#####.###.#####.#######.#####.#.#.#########.#.#######.###.#####.#.###.#.#.#.#.#.#.#####.#.#.# -#...#$..#.$...#$..#.$.#..$..#.$.#..$....$...#$..#.$...#$....$...#$#.#.$.#..$..#.$.#.#$#.#.$....$#.#.# -###.#.#.#.#####.###.#.#####.#.###########.###.#.#####.#.#.#####.#.#.#.###.#####.#.###.#.#########.#.# -#...#.#.#.#...#.....#.....#...#.....#...#.#...#.#...#.#.#...#...#.#.....#.#.....#...#.#.......#...#.# -#.###.###.#.#.###########.#####.###.#.#.###.###.#.#.###.###.#.###.#.###.###.#######.#.#.#####.#.###.# -#...#.......#...........#.........#...#.......#...#.......#...#.......#...........#.....#.......#.... -##################################################################################################### - -##################################################################################################### -#.........#.........#...#.................#.....#.....#...........#...#.....#.....#...........#.....# -#####.###.#.#######.#.#.###.###.###########.#.###.#.#.###.#######.###.#.#.#.###.#.#####.#.###.#.###.# -#.....#...#.......#...#...#...#.#...#.......#.....#.#...#.....#.#...#...#.#...#.#.....#.#.#.....#.#.# -#.###############.#######.###.###.#.#.#############.###.#####.#.###.#####.###.#.#####.#.#.#.#####.#.# -#....$#...$....$#...$.#.#$..#.$...#$..#.$...#$....$...#$..#.$.#..$#...$...#$..#.$....$#.#.$.#..$#.#.# -#####.#.#.#.###.#####.#.###.#.#############.#.###.#.#.###.#.###.###.#######.###.#.#####.#.###.#.#.#.# -#.....#.#.....#.....#.#...#.#.....#.........#...#.#.#.#...#.#.......#...#.......#...#...#.#...#.#...# -#.###.#.#########.###.###.#.#####.###.###.#####.#.###.#.###.###.#####.#.###########.#####.#.###.#.### -#.#...#...#.....#.#.......#.....#.....#...#.....#...#.#...#...#.#.....#.#.........#.....#...#...#.#.# -#.###$###.$.###$#.#.$####$####$.###$###.$##.#$####$.#.#$#.##$.###$####$.#.#$####$.###$#.##$##.#$#.#.# -#...#.....#.#...#...#...#.....#.#.#.......#.#.....#...#.#...#...#...#...#.#...#.#.#.....#.....#...#.# -#.#.#.#####.###.###.#.#.#.###.#.#.#.#######.#.###.#####.###.#.#.###.#.#.#.#.#.#.#.###.###.#####.###.# -#.#.#.....#...#...#.#.#.....#...#...#.......#...#...#...#...#.#.#...#.#.#.#.#...#...#.#.....#.#.#...# -#.#.#.#######.###.###.#####.#####.###.#########.#.#.#.###.#####.#.###.#.#.#.#######.#.#####.#.#.#.#.# -#.#..$#...$...#$#...$.#..$#...$...#$..#.$....$..#.$...#$..#.$...#$..#.$.#..$#...$...#$#...$.#.#$#.#.# -#.#####.#######.#######.#.#.#.#.###.###.#########.#.###.###.#######.#.#####.#.#######.#.#.#.#.#.#.#.# -#.#...#.....#.......#...#.#.#...#...#...#.......#.#.#.......#.......#.....#.#.....#.....#...#.#...#.# -#.#.#.#####.#.###.#.###.#.#.#####.#####.###.###.#.###.#######.#########.###.#####.###########.#####.# -#...#.#...#.#.#...#...#.#...#...#.....#...#...#.#.....#.#...#...#.#...#...#.#...#.......#...#.....#.# -#####$#.#.$.###$####$.###$###.$.###$#.##$.###$#.##$####$#.#.$##.#$#.#.$##.#$#.##$##.#$#.#.$##.#$###.# -#.....#.#.#...#.#...#.........#.....#.#.#.....#.........#.#.....#...#...#.#.#.#...#...#.#...#.#.....# -#.#####.#.###.#.#.#.###############.#.#.#####.#.#######.#.###########.#.#.#.#.#.#.#####.###.#.####### -#.#.#...#...#.#...#...#...#.......#...#.....#...#.#.....#.............#.#...#.#.#.#.....#...#.....#.# -#.#.#.#####.#.#####.#.#.#.#######.#####.###.#####.#.###############.#######.#.#.#.#.#####.#.#####.#.# -#.#.#$..#.$...#$..#.$.#.#$....$.#..$..#.$.#..$#...$.#..$....$....$#.#.$...#$..#.$...#$....$...#$..#.# -#.#.###.#.#####.#.###.#.#######.#.###.###.#.###.#####.#######.#####.#.###.#####.#####.#.#######.###.# -#.#...#.#.#.....#...#...#.......#...#.....#.#...#.....#.....#.......#.#...#...#...#...#...#...#.#...# -#.#.#.#.###.#######.#####.#.#######.#####.#.#.###.#####.#############.###.#.#.###.###.###.#.#.#.###.# -#.#.#.#.....#.#.....#.....#.#.....#.#...#.#...#...#...........#.#...#...#...#...#...#...#...#.#.#...# -#.#.#$####$##.#$####$.###$#.#.$##.#$#.#.$####$#.##$####$###.$.#.#$#.##$.###$###.$##.#$#.##$##.#$#.#.# -#.#.#...#.....#.....#...#.#.#.#.#.....#.#...#.#...........#.#.#...#...#.#...........#.#.....#...#.#.# -#.#####.#.#.#.#####.#.#.#.#.#.#.#######.#.#.###.#########.#.#.#####.#.#.#############.#####.#####.### -#.....#...#.#.....#.#.#.#...#.#.......#.#.#...#.#.......#.#.#.......#.#...........#.......#.....#...# -#####.#.###.#.#######.#.###.#.#.#####.#.#.###.#.#.#####.#.#.#######.#####.#######.#.###.#.#####.#.#.# -#...#$#...$.#.#$....$.#..$#.#.$....$#.#.$.#.#$..#.$...#$#...$....$#.#.$.#..$....$.#.#$..#.$...#$#.#.# -###.#.###.#.###.###.#.###.###.#######.#.#.#.#####.#.###.#######.###.#.#.#######.#.###.#.###.#.#.###.# -#...#.#...#...#...#.#...#...#.#.......#...#.....#.#.....#.......#...#.#.#.....#.#.#...#.#...#.#.#...# -#.#.#.#.#####.###.#.###.###.#.#.#####.#######.###.#.#####.#####.#.###.#.#####.#.#.#.#####.###.#.#.### -#.#.#.#.#...#.....#.....#.#...#.....#.........#...#...#.......#.#.#.#.#.....#...#.#.........#.#.#...# -#.###$#.#.$.###$####$##.#$####$####$###.$####$#.##$##.#$####$.###$#.#.$####$#.##$.#.#$####$##.#$###.# -#.....#...#.#.........#.....#.....#...#.#.......#...#.#.....#.......#.....#.#...#.#...#.....#...#...# -#.#######.###.#.#####.#####.#.###.#.#.###.#######.#.#.###################.#.###.#.#####.###.###.#.#.# -#...#...#.#...#.#...#.....#...#...#.#...#.......#.#.#.......#.......#.....#.#...#.....#.#.#...#...#.# -###.###.#.#.#####.#.#####.#######.#####.#######.#.#.#######.#.#####.#.#####.#.#######.#.#.###.####### -#.#..$#.#.$....$..#.$...#$....$.#..$#...$...#$..#.$....$#...$....$#...$....$#...$....$#.#.$.#.#$....# -#.###.#.#.#########.#.#########.###.#.#.#####.###.#.#####.#######.#####.#####.###.#####.###.#.#.###.# -#.....#.#...#...#...#...#.....#.#.....#.#.....#.#.#...............#...#...#...#...#.........#...#...# -#.#####.###.###.#.###.#.#.#.###.#########.#####.#.###################.###.###.#.###.#######.#####.### -#.#.......#.....#.#...#...#...#.#.......#.#...#...#.......#...........#.#...#.#.......#...#.....#...# -#.###$###.$.###$#.#.$####$#.#.$.#.#$###.$.#.#$####$.###$#.#.$.###$###.$.###$#.##$####$#.#.$.###$#.#.# -#.#...#...#.#.....#...#.....#.#...#...#.#.#.#.....#.....#.#.#.#...#.#...#...#...#...#...#.#.#...#.#.# -#.#.#.#.###.#.#######.#.#####.#####.###.#.#.#####.#####.#.###.#.#.#.#.###.#####.#.###.###.#.#.#.###.# -#...#.#.....#.#.....#...#...#.......#...#...#...#.....#.#...#.#.#.#...#...#...#.#...#.#.#.#.#.#.#...# -#####.#.#####.#.###.#.###.#.#####.#.#.###.###.#.#.#.###.###.#.#.#.###.#.###.###.###.#.#.#.#.#.#.#.#.# -#...#$#...$...#$..#.$.#..$#...$...#$#.#.$...#$#.#.$.#..$#.#.$...#$..#.$.#..$....$...#$#...$.#.#$..#.# -#.###.###.#.###########.###########.#.#####.#.#.###.#.###.#.#.#####.###.#.#########.#.#.###.#.#####.# -#...#...#.#.#...........#...#...#...#...#...#.#...#.#.....#.#.....#.....#.#...#.....#.#...#.#.#.#...# -#.#.###.###.#.#.#########.#.#.#.#.#####.#####.###.#.###.###.#####.#######.#.#.#######.###.###.#.#.### -#.#...#.....#.#.......#...#...#.#.#...#.......#...#...#.#...#...#...#.....#.#...#.....#.#...#.#...#.# -#.###$####$##.#$####$.#.#$####$.#.#$#.##$####$#.##$.#.#$#.##$.###$#.##$####$###.$.###$#.##$.#.#$###.# -#...#...#.#...#.....#...#.....#.#.............#.#.#.#...#.#...#...#...#.....#.#.#.....#...#...#...#.# -#.###.#.#.#.###.#####.#######.#.#############.#.#.#.#####.#.###.#.###.#.#####.#.#####.#.#.#######.#.# -#.#...#.#.#.#...#...#...#.....#.#...........#.#.#...#...#.#.....#...#...#...#.#.......#.#.......#.#.# -###.###.#.#.#.#.#.#.###.#.###.#.#.###########.#.###.#.#.#.###.#####.###.#.#.#.#########.#######.#.#.# -#...#$#.#.$.#.#$#.#.$...#$..#.$.#..$....$...#$#...$.#.#$#...$....$#...$...#$#...$....$....$....$#...# -#.###.#.#.#.#.###.#.###.###.#.#.#########.#.#.###.###.#.###.#####.###.#####.###.#.#########.###.###.# -#.#...#.#.#.#.#...#...#.....#.#.....#...#.#...#...#...#.....#.....#...#.......#.......#.....#.....#.# -#.#.###.#.#.#.#.#####.#######.#####.#.#.#######.###.#########.#####.#########.#######.#.#####.#####.# -#.#.....#.....#...#.........#.....#.#.#.......#.....#.........#.....#...#...#.......#.#.....#.#.....# -#.###$####$##.#$#.##$####$#.##$##.#$#.##$####$####$####$####$##.#$###.$.#.#$####$##.#$#.##$.###$##### -#...#.......#...#.......#.......#.#.#.#.....#.........#...#...#.......#...#.#.....#...#.#.#...#.#...# -#.#.#######.#.#####.###.#.#####.###.#.###.#####.#####.#####.#.#######.#####.#####.###.#.#.###.#.#.#.# -#.#.......#.#.#...#.#...#.#...#.....#...#.#.....#...#...#...#.#.....#.....#.#...#...#.#...#...#...#.# -#.#######.#.#.#.#.###.#.###.#.#####.###.#.#.#######.###.#.###.#.###.#######.#.#.###.#.###.#.#.#####.# -#...#$..#.$.#.#$#...$.#.#$..#.$....$#.#.$.#..$....$....$#.#.$.#..$#...$....$#.#.$.#..$#...$.#.#$....# -###.###.#.#.#.#.###.#.###.###.###.###.#.#.#######.###.###.#.#.#.#.#####.#####.###.#.#######.###.##### -#.....#.#.#.#.#...#.#.#...#.#...#.#...#.#...#...#...#.#...#...#.#.#...#.#.....#.#.#.......#...#.#...# -#####.#.#.#.#.###.#.#.#.###.###.#.#.###.#.#.#.#.###.#.#.#.#.###.#.#.#.###.#####.#.#######.###.#.#.#.# -#...#...#.#.#.#...#...#.#.....#.#.#...#...#.#.#.#...#.#.#.#...#.#...#...........#.......#.#...#.#.#.# -#.#.#$###.$.###$####$.#.#$###.$.#.#$#.##$##.#$###.$##.#$#.##$.###$###.$####$####$##.#$#.#.$.#.#$#.#.# -#.#.......#.....#.#...#.#.#...#.#.....#...#.#.#...#.......#...#.....#.#.#.....#...#.#...#...#.#.#.#.# -#.#####.#########.#.###.###.#.#.###.###.#.#.#.#.###########.###.###.#.#.#.###.#.#.###.#######.#.#.#.# -#.#...#.#...#...#...#.#.#...#.#.#...#...#...#.#.....#.....#...#.#...#...#.#.....#.#...#.......#...#.# -#.#.#.###.#.#.#.#.###.#.#.###.#.###.#.#######.#####.#.#.#.###.#.###.###.#.#######.#.###.###########.# -#.#.#$....$.#.#$#.#.$.#..$#...$...#$#.#.$....$#...$.#.#$#.#.$.#..$#...$.#..$#...$...#$#.#.$...#$....# -#.#.#######.#.###.#.#.#####.#####.###.#.#.###.#.#.#.###.###.#####.###.#####.#########.#.#.###.#.##### -#...#.......#.....#.#.#.....#...#.#...#.#.#.#...#.#...#...#.......#.........#...#.......#.#.#.#.....# -#.###.###########.#.###.#######.#.#.#####.#.#####.###.#.#.#########.#########.#.#######.#.#.#.#####.# -#.#.#.......#...#...#...#.....#.#.#.#.....#.#.....#.#.#.#...........#.........#.#.....#.#...#.....#.# -#.#.#$####$.#.#$###.$.###$###.$.#.#$#.##$##.#$####$.#.#$####$##.#$###.$####$###.$.###$###.$##.#$###.# -#.#.......#...#.#.#.#.#...#.....#.#.#.#...#...#.....#.........#...#.#.#...#.....#...#.....#...#.....# -#.#.###.#######.#.#.#.###.#######.#.#.#.#.#.###.###.#########.###.#.#.###.#.#######.#######.#.#.##### -#...#...#...#...#...#...#.#.....#.#...#.#.#...#.#.......#...#...#...#.#...#.#.......#.......#.#.....# -###.#####.#.#.###.#####.#.#.###.#.#####.#####.#.#######.#.#.#.#.#####.#.###.#.#######.#############.# -#...#$..#.$...#$....$...#$#.#.$...#$..#.$....$#...$.#..$#.#.$.#..$..#.$.#..$#.#.$...#$..#.$...#$....# -#.###.#.#.#########.#.###.#.#######.#.#.#######.#.#.#.###.#.#######.###.#.###.#.###.###.#.###.#.##### -#...#.#...#...#...#.#...#.#.#.......#...#.....#.#.#.#.#.#.#.........#...#...#.#...#.#.#.#.#...#.#...# -###.#.#####.#.#.#.#####.#.#.#.###########.###.###.#.#.#.#.###########.#####.#.###.#.#.#.#.#.###.#.#.# -#...#.......#...#.........#...............#.......#.....#.................#.......#...#...#.......#.# -#####################################################################################################
\ No newline at end of file diff --git a/codingquest2024/src/day9/solution.gleam b/codingquest2024/src/day9/solution.gleam deleted file mode 100644 index e69de29..0000000 --- a/codingquest2024/src/day9/solution.gleam +++ /dev/null diff --git a/codingquest2024/src/utilities/memo.gleam b/codingquest2024/src/utilities/memo.gleam deleted file mode 100644 index b06d8fd..0000000 --- a/codingquest2024/src/utilities/memo.gleam +++ /dev/null @@ -1,57 +0,0 @@ -import gleam/dict.{type Dict} -import gleam/otp/actor.{type Next, Continue, Stop} -import gleam/erlang/process.{type Subject, Normal} -import gleam/option.{None} - -const timeout = 1000 - -type Message(k, v) { - Shutdown - Get(key: k, client: Subject(Result(v, Nil))) - Set(key: k, value: v) -} - -type Server(k, v) = - Subject(Message(k, v)) - -pub opaque type Cache(k, v) { - Cache(server: Server(k, v)) -} - -fn handle_message( - message: Message(k, v), - dict: Dict(k, v), -) -> Next(Message(k, v), Dict(k, v)) { - case message { - Shutdown -> Stop(Normal) - Get(key, client) -> { - process.send(client, dict.get(dict, key)) - Continue(dict, None) - } - Set(key, value) -> Continue(dict.insert(dict, key, value), None) - } -} - -pub fn create(apply fun: fn(Cache(k, v)) -> t) -> t { - let assert Ok(server) = actor.start(dict.new(), handle_message) - let result = fun(Cache(server)) - process.send(server, Shutdown) - result -} - -pub fn set(in cache: Cache(k, v), for key: k, insert value: v) -> Nil { - process.send(cache.server, Set(key, value)) -} - -pub fn get(from cache: Cache(k, v), fetch key: k) -> Result(v, Nil) { - process.call(cache.server, fn(c) { Get(key, c) }, timeout) -} - -pub fn memoize(with cache: Cache(k, v), this key: k, apply fun: fn() -> v) -> v { - let result = case get(from: cache, fetch: key) { - Ok(value) -> value - Error(Nil) -> fun() - } - set(in: cache, for: key, insert: result) - result -} diff --git a/codingquest2024/test/codingquest2024_test.gleam b/codingquest2024/test/codingquest2024_test.gleam deleted file mode 100644 index 3831e7a..0000000 --- a/codingquest2024/test/codingquest2024_test.gleam +++ /dev/null @@ -1,12 +0,0 @@ -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) -} |