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
Photo, no description
Photo, no description
Photo, no description
Photo, no description
library(igraph)
x <- readLines("input.txt")
e <- do.call(rbind, lapply(strsplit(x, "-"), \(z)
                           cbind(z[1], strsplit(z[2], ",")[[1]])))
g <- graph_from_edgelist(as.matrix(e), FALSE)
c <- V(g)$name[degree(g) == 2] # ID the corners, w. 2 neighbours
d <- combn(c, 2, \(p) distances(g, p[1], p[2])[1], simplify = TRUE)
# Corner to corner path lengths
a <- combn(c, 2)[, which.min(d)] # pick adjacent corners (shortest distance)
k <- min(d) # side length of square
da <- distances(g, a[1], V(g))[1, ] # light to lights fom corner A
db <- distances(g, a[2], V(g))[1, ] # light to lights fom corner B
V(g)$name[
  (db - da + k) / 2 == k / 2 &
    da - (db - da + k) / 2 == k / 2
] # centre is equidistant
# Part 2
# Identify the four grid corners.
c <- V(g)$name[degree(g) == 2]
# Find opposite corners (distance 80) and adjacent corners (distance 40).
p <- t(combn(c, 2))
o <- p[which.max(apply(p, 1, \(x) distances(g, x[1], x[2])[1])), ]
a <- setdiff(c, o)
# unique row/column lattice coordinates for every light.
d1 <- distances(g, o[1], V(g))[1, ]
d2 <- distances(g, a[1], V(g))[1, ]
d3 <- distances(g, a[2], V(g))[1, ]
coords <- data.frame(id  = V(g)$name,row = (d1 - d3 + 40) / 2,
                     col = (d1 - d2 + 40) / 2)
# target coords
tgt <- data.frame(id = c("1","2","3"),X  = c(47,29,56),Y  = c(30,59,35))
# all possible versions
sym <- list(
  \(x,y)cbind( x, y), \(x,y)cbind( y,-x),
  \(x,y)cbind(-x,-y), \(x,y)cbind(-y, x),
  \(x,y)cbind(-x, y), \(x,y)cbind( x,-y),
  \(x,y)cbind( y, x), \(x,y)cbind(-y,-x))
# DB merge candidates and versions
A <- merge(coords, tgt)
# check which versions
for(f in sym) {
  p <- f(A$col, A$row)
  tx <- A$X[1] - p[1,1]
  ty <- A$Y[1] - p[1,2]
  if(all(p[,1] + tx == A$X) && all(p[,2] + ty == A$Y)) {
    z <- f(coords$col, coords$row)
    coords$X <- z[,1] + tx
    coords$Y <- z[,2] + ty
    break
  }
}
coords[coords$id == "2026", c("X","Y")]
Photo, no description
Photo, no description
Photo, no description
Photo, no description
Photo, no description
Photo, no description
Blog post image
Before vs. After: TRIPOD Calibration & Decision Curve Analysis (Zero Wrapper Hell)
Blog post image
Photo, no description
Photo, no description
Blog post image
River map of Australia on a black background. Every river is a thin coloured line, coloured by the basin it drains into, in a patchwork of reds, blues, greens, purples and oranges. Tasmania sits below in gold.
creating a combination out of a vector of functions produces a matrix whose elements print as question marks
Load more