Run this notebook

Use Livebook to open this notebook and explore new ideas.

It is easy to get started, on your machine or the cloud.

Click below to open and run it in your Livebook at .

(or change your Livebook location)

# Untitled notebook ## Section ```elixir defmodule Aoc2024.Day4 do def find_word_count(grid, word) do for row <- (0..length(grid) - 1) do for col <- (0..length(Enum.at(grid, 0)) - 1) do IO.inspect("checking #{word} at #{row}, #{col}") end end end def search_at(grid, word, row, col) do # row_delta, col_delta directions = [ {0, 1}, # search right {0, -1}, # search left {1, 0}, # search down {-1, 0}, # search up {1, 1}, #diag down right {-1, 1}, #diag down left {-1, 1}, #diag up right {-1, -1}, #diag up left ] end end ``` ```elixir input = "MMMSXXMASM MSAMXMSMSA AMXSXMAAMM MSAMASMSMX XMASAMXAMM XXAMMXXAMA SMSMSASXSS SAXAMASAAA MAMMMXMMMM MXMXAXMASX" grid = input |> String.split("\r\n", trim: true) |> Stream.map(&String.graphemes()/1) |> Enum.to_list() row_count = length(grid) col_count = length(Enum.at(grid, 0)) search_word = "XMAS" Aoc2024.Day4.find_word_count(grid, search_word) ```
See source

Have you already installed Livebook?

If you already installed Livebook, you can configure the default Livebook location where you want to open notebooks.
Livebook up Checking status We can't reach this Livebook (but we saved your preference anyway)
Run notebook

Not yet? Install Livebook in just a minute

Livebook is open source, free, and ready to run anywhere.

Run on your machine

with Livebook Desktop

Run in the cloud

on select platforms

To run on Linux, Docker, embedded devices, or Elixir’s Mix, check our README.

PLATINUM SPONSORS
SPONSORS
Code navigation with go to definition of modules and functions Read More ×