Grilled Cheese

ExploreLog inSign up
Terms of UsePrivacy PolicyCommunity StandardsHelpGet the app

Grilled Cheese is a product of Village Compute

Version devBuilt at: 2026-12-03 22:42:33 EST

PhotosVideosAllPeople
LatestRanked
dec03 =>

  input := io.stdin.read_lines! .map (.codepoints.map ="#" .force) .force
  w => input.count
  a := array2 w w y,x->input[y][x]
  i(y,x) => 0 <= y < w && 0 <= x < w && input[y][x]

  part1 =>
    a.index_pairs.filter ||>i
                 .sum ||>y,x->
                    (1 .. w-1-max y x).count s->
                      (i y   x+s &&
                       i y+s x   &&
                       i y+s x+s    )

  part2 =>
    a.index_pairs.filter ||>i
                 .sum ||>y,x->
                    (1 .. w-1).sum s->
                                (0..(s-1)).count r->
                                  (i y+r   x+s-r   &&
                                   i y+s-r x-r     &&
                                   i y+s   x+s-2*r    )

  Sequence.sum(f T -> N : numeric) => map f .sum

  say "$part1:$part2"
Photo, no description
Photo, no description
Advent of Code Day 2 in APL - Asher Harvey Smith
Advent of Code day 3 part 1 screenshot
Photo, no description
package day03

import kodvent.grid.Grid
import kodvent.grid.Position

class Day03 {
    fun part1(grid: Grid<Char>): Int = grid.squareSides().count { it.y == 0 }

    fun part2(grid: Grid<Char>): Int = grid.squareSides().size

    private fun Grid<Char>.squareSides(): List<Position> {
        val trees = positionsOf('#')
        return trees.flatMap { a ->
            trees.map { it - a }.filter { side ->
                val next = side.turnRight()
                side.x > 0 && side.y >= 0 && getOrNull(a + next) == '#' && getOrNull(a + side + next) == '#'
            }
        }
    }

    private fun Position.turnRight() = Position(-y, x)
}
Photo, no description
Tremendo galimatías en 6 lineas de Lisp (las lineas más largas están cortadas):

```lisp
(defun aoc26/day1 (beg end &optional min)
  (interactive "r\nP")
  (let* ((ids seq-map #'string-to-number (string-lines ...
      (counts aoc26/sort-table-by-value (aoc26/utils ...
      (result apply #'s (mapcar #'car (take 3 counts ...
    (message "%d" result)))
Photo, no description
{
  module T = Set.Make(struct type t = int * int let compare = compare end)
}

rule map trees i j = parse
| '#' { map (T.add (i, j) trees) i (j+1) lexbuf }
| '.' { map trees i (j+1) lexbuf }
| '\n' { map trees (i+1) 0 lexbuf }
| eof { trees }

{
  let ts = map T.empty 0 0 (Lexing.from_channel stdin) in
  let to_check (i, j) = T.(filter (fun (i', j') -> i' <= i && j' > j) ts |> to_list) in
  let is_square (i, j) (i', j') = T.(mem (i+j'-j, j-i'+i) ts && mem (i'+j'-j, j'-i'+i) ts) in
  let (+^) n b = n + Bool.to_int b in
  let count_squares t = List.(map (is_square t) (to_check t) |> fold_left (+^) 0) in
  Printf.printf "%d\n" List.(map count_squares (T.elements ts) |> fold_left (+) 0)
}
Commodore 64 screen, with big blocky text all in capitals. It has a set of test cases, and the result of running them - including pass announcements in green with hearts, and fails in red with a big cross.
# For a given #A....#B in a row it is a square if 
# A = (r,c) B = (r,c+d) C = (r+d,c) D = (r+d,c+d) where D = Ac - Bc
input = readLines("input.txt")
# Build logical grid
grid <- do.call(
  rbind,
  lapply(
    input,
    function(x) strsplit(x, "", fixed = TRUE)[[1]] == "#"
  )
)
n_rows <- nrow(grid)
n_cols <- ncol(grid)
square_count <- 0
for (d in 1:140) { #140 is max gap
  # rows participating in a square of edge d
  upper_rows <- seq_len(n_rows - d)
  lower_rows <- upper_rows + d
  # columns participating in a square of edge d
  left_cols  <- seq_len(n_cols - d)
  right_cols <- left_cols + d
  #if hypothetical squares exist increase count
  square_count <- square_count +
    sum(
      grid[upper_rows, left_cols,  drop = FALSE] &
        grid[upper_rows, right_cols, drop = FALSE] &
        grid[lower_rows, left_cols,  drop = FALSE] &
        grid[lower_rows, right_cols, drop = FALSE]
    )
}
square_count
#Star2
trees <- which(grid, arr.ind = TRUE)
n_trees <- nrow(trees)
square_count <- 0L
for (i in seq_len(n_trees - 1)) {
  r1 <- trees[i, 1]
  c1 <- trees[i, 2]
  for (j in (i + 1):n_trees) {
    r2 <- trees[j, 1]
    c2 <- trees[j, 2]
    dx <- r2 - r1
    dy <- c2 - c1
    # 1st direction
    r3 <- r1 - dy
    c3 <- c1 + dx
    r4 <- r2 - dy
    c4 <- c2 + dx
    if (
      r3 >= 1 && r3 <= n_rows &&
      r4 >= 1 && r4 <= n_rows &&
      c3 >= 1 && c3 <= n_cols &&
      c4 >= 1 && c4 <= n_cols
    ) {
      if (
        grid[r3, c3] &&
        grid[r4, c4]
      ) {
        square_count <- square_count + 1L
      }
    }
    # other direction
    r3 <- r1 + dy
    c3 <- c1 - dx
    r4 <- r2 + dy
    c4 <- c2 - dx
    if (
      r3 >= 1 && r3 <= n_rows &&
      r4 >= 1 && r4 <= n_rows &&
      c3 >= 1 && c3 <= n_cols &&
      c4 >= 1 && c4 <= n_cols
    ) {
      if (
        grid[r3, c3] &&
        grid[r4, c4]
      ) {
        square_count <- square_count + 1
      }
    }
  }
}
# squares not edges
square_count <- square_count %/% 4
square_count
Photo, no description
A screenshot of my times for Day 1-3 of Advent of Code 2026.

Day 3
Part 1: 00:05:51
Part 2: 00:30:13

Day 2
Part 1: 00:07:22
Part 2: 00:16:51


Day 1
Part 1: 23:15:13
Part 2: 23:16:56
Screenshot of Day 2's completion with the text "That's Right!!" signifying that a response from the server has confirmed that the solution it calculated is correct. The background is a still from the Polar Express (2004) trailer.
Photo, no description
Photo, no description
program <- "roygbvroygbvroygbv" 

program <- program |> 
  strsplit("") |> 
  unlist() |> 
  c("^", ..2 = _)

names <- c("^", "r", "o", "y", "g", "b", "v")
m <- matrix(
  c(
    0, 6, 1, 2, 3, 4, 5,
    6, 6, 1, 2, 3, 4, 5,
    5, 5, 6, 1, 2, 3, 4,
    4, 4, 5, 6, 1, 2, 3,
    3, 3, 4, 5, 6, 1, 2,
    2, 2, 3, 4, 5, 6, 1, 
    1, 1, 2, 3, 4, 5, 6
  ),
  byrow = TRUE, 
  nrow = 7
)

colnames(m) <- names
rownames(m) <- names
answer1 <- m[program, program][, -1] |> diag() |> sum()

long_way <- c("r", "v", "b", "g", "y", "o")
program2 <- program[-1] |> 
  factor(levels = long_way) |> 
  sort() |> 
  as.character() |> 
  c("^", ..2 = _)
answer2 <- m[program2, program2][, -1] |> diag() |> sum()
Load more