some useful code to support generic puzzle solving...