A grope is a set
is satisfied for all
The art of computer programming, Vol. 4B, p.132, problem 75.b
| #lang racket | |
| (require math/array) | |
| (define ((make-mul table) x y) | |
| (array-ref table (vector x y))) | |
| (define (table-grope? table) | |
| (define n '(0 1 2 3)) | |
| (define mul (make-mul table)) | |
| (for/and ([l (cartesian-product n n)]) | |
| (match-define (list x y) l) | |
| (= (mul x (mul y x)) y))) | |
| (table-grope? (array #[#[0 1 2 3] | |
| #[1 0 3 2] | |
| #[2 3 0 1] | |
| #[3 2 1 0]])) | |
| (table-grope? (array #[#[0 3 2 1] | |
| #[3 2 1 0] | |
| #[2 1 0 3] | |
| #[1 0 3 2]])) | |
| (table-grope? (array #[#[0 1 3 2] | |
| #[1 0 2 3] | |
| #[3 2 1 0] | |
| #[2 3 0 1]])) | |
| (table-grope? (array #[#[0 2 3 1] | |
| #[3 1 0 2] | |
| #[1 3 2 0] | |
| #[2 0 1 3]])) | |
| (table-grope? (array #[#[0 3 1 2] | |
| #[2 1 3 0] | |
| #[3 0 2 1] | |
| #[1 2 0 3]])) |