#! /usr/bin/env lua package.path = "?.lua;cgi-bin/?.lua;www/cgi-bin/?.lua" local moth = require "moth" local max_by_cat = {} local f = io.popen("ls " .. moth.path("packages")) for cat in f:lines() do max_by_cat[cat] = 0 end f:close() for line in io.lines(moth.path("state/points.log")) do local ts, team, cat, points, comment = line:match("^(%d+) (%w+) ([%w-]+) (%d+) ?(.*)") points = tonumber(points) or 0 -- Skip scores for removed categories if (max_by_cat[cat] ~= nil) then max_by_cat[cat] = math.max(max_by_cat[cat], points) end end local body = "
\n" for cat, biggest in pairs(max_by_cat) do local points, dirname body = body .. "
" .. cat .. "
" body = body .. "
" for line in io.lines(moth.path("packages/" .. cat .. "/map.txt")) do points, dirname = line:match("^(%d+) (.*)") points = tonumber(points) body = body .. "" .. points .. " " if (points > biggest) then break end end if (points == biggest) then body = body .. "" end body = body .. "
\n" end body = body .. "
\n" body = body .. "
Sandia Token:" body = body .. "

Example: sandia:5:xylep-radar-nanox

" body = body .. "
" body = body .. "Team Hash:
" body = body .. "Token: " body = body .. "" body = body .. "
" body = body .. "
" body = body .. "

Reloading this page periodically may yield updated puzzle lists.

" moth.page("Open Puzzles", body)