It’s been a few weeks since I found a puzzle worth programming in R, so I turned back to the RR series in the east of England to see if there was another, and there is.

The cache page shows a quite unilluminating image, mostly white with a couple of small characters. Opening the image in a new tab, I could see the image was similar but different. Ok, so this is one of those caches where PHP is used to serve up an image that changes. Sometimes these can be tricky, involving long waits, or lots of gathering information before you can even see the extent of the puzzle. But I suspected this one was more straightforward: it would be just a case of gathering a bunch of the images and overlaying them on each other to show the letters all in single frame. I shudder to think how I would go about this without R, so let’s get coding:

URL <- ""
dr <- "C:/Users/alunh/OneDrive/Documents/Repos/geo2/Solving/GC4XMN7_rr138-404-found/"
for (q in 1:80) {
  tid <- as.character(round(as.numeric(Sys.time())*1000, 0))
  download.file(URL, destfile = paste0(dr, tid, ".gif"), mode = 'wb')
} # download 80 versions of the image
  list.files(dr, full.names = TRUE, pattern="gif"),
  function(q) {
  read.gif(filename = q)$image
) %>% 
  c(list(along=3)) %>% %>% 
  apply(1:2, max) %>% # every time a non-black pixel is found, preserve it
  apply(1, rev) %>% # this is a lazy way of rotating the matrix so it image()s the right way up 
  apply(1, rev) %>% # this is a lazy way of rotating the matrix so it image()s the right way up 
  apply(1, rev) %>% # this is a lazy way of rotating the matrix so it image()s the right way up
  image(col=c("black", "white"))

The image shows the partial result of the plot (I’ve kept it partial to avoid spoilers), but the pattern is clear: a cross of letters, spelling out the north coordinates vertically and the east coordinates horizontally. Job done!

It took a little searching to remind myself how to read in GIFs — the caTools library is the answer. It’s a slight oddity that there isn’t a package called gif, analogous to the jpeg and png packages, but there’s no gap in the functionality.

Also putting in a welcome appearance is one of my favourite R tricks, rotating a matrix using the simplest of commands: apply(m, 1, rev). I don’t mind admitting I get a frisson of pleasure whenever I get to use that, because it’s so elegant.

Last time, I mentioned that I “discovered” a new integer sequence. After a length submission and review process, it was found that I hadn’t, in fact. I’d just found an existing one and put a slightly odd twist on it. I withdrew my submission, but my thanks go to the editors of for their patience and diligence in dealing with my attempt to get my name into that most nerdy hall of fame. One day.

Published by densurekalkun

Leave a comment

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: