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
Photo, no description
let sorted = In_channel.input_lines stdin |> List.map int_of_string
  |> List.sort compare |> List.fold_left
    (fun acc id ->
      match acc with
      | (pre, c) :: r when id = pre -> (id, c+1) :: r
      | r -> (id, 1) :: r) []
  |> List.sort (fun (_, c) (_, c') -> compare c' c)
  |> List.map fst

let () =
  Printf.printf "%d\n%d\n"
    List.(sorted |> take 3 |> fold_left ( * ) 1)
    List.(rev sorted |> take 3 |> fold_left ( * ) 1)
Advent of Code 2026 calendar page with green ASCII art of houses and a train on a dark background. Day 1 shows two gold stars, and day 2 shows a countdown of 14:23:23.
Screenshot of the Advent of Code website, showing Ascii art of a a train on a track that's just passed through some red and green houses, one with a star outside
import pandas as pd
import numpy as np

containers = pd.read_csv("day01/input", names = ["container"])

# Part I
np.prod(containers["container"].value_counts().head(3).index.to_numpy())

# Part II
np.prod(containers["container"].value_counts().tail(3).index.to_numpy())
Spiral with many different colours wrapped around text that says Advent of Code 2026 Day 1.
Advent of Code 2026 day 1 solution screenshot
Photo, no description
Photo, no description
Photo, no description
Photo, no description
Photo, no description
library(tidyverse)

containers = read_csv("day01/input", col_names = "container")

# Parts I and II
containers %>% 
  count(container, sort = TRUE) %>% 
  #slice_head(n = 3) %>% 
  slice_tail(n = 3) %>% 
  summarise(prod(container))
Photo, no description
Photo, no description
Photo, no description
Bash: echo $(($(cat | sort | uniq -c | sort -nr | head -3 | rev | cut -d' ' -f1 | rev | tr '\n' '*')1))

OCaml :

rule ids = parse
| ['0' - '9']+ as id { int_of_string id :: ids lexbuf }
| '\n' { ids lexbuf }
| eof { [] }

{
  ids (Lexing.from_channel stdin)
  |> List.sort compare
  |> List.fold_left (fun acc id ->
    match acc with
    | (pre, c) :: r when id = pre -> (id, c+1) :: r
    | r -> (id, 1) :: r) []
  |> List.sort (fun (_, c) (_, c') -> compare c c')
  |> List.take 3
  |> List.map fst
  |> List.fold_left ( * ) 1
  |> Printf.printf "%d\n"
}
Photo, no description
Photo, no description
Load more