Discussion:
New Scientist Puzzle
(too old to reply)
B. Pym
2024-06-11 08:51:08 UTC
Permalink
VIER and NEUN represent 4-digit squares, each letter denoting a
distinct digit. You are asked to find the value of each, given the
further requirement that each uniquely determines the other.

The "further requirement" means that of the numerous pairs of
answers, choose the one in which each number only appears once
in all of the pairs.

Gauche Scheme

(use srfi-13) ;; string-map
(use srfi-42) ;; list-ec

(define squares4d
(map (lambda (n) (number->string (square n)))
(lrange 32 100)))

(define alphabet (map integer->char (lrange 65 91)))

(define (->pattern str)
(let ((table
(map cons
(delete-duplicates (string->list str))
alphabet)))
(string-map (cut assoc-ref table <>) str)))

(define possibles
(let ((pat (->pattern "NEUNVIER")))
(list-ec
(:list n squares4d)
(:list v squares4d)
(if (equal? pat (->pattern (string-append n v))))
(list n v))))

(define (count* f xs)
(count (lambda(ys) (equal? (f xs) (f ys))) possibles))

(find
(lambda(nv) (= 1 (count* car nv) (count* cadr nv)))
possibles)

===>
("9409" "6241")
HenHanna
2024-06-11 21:37:42 UTC
Permalink
Post by B. Pym
VIER and NEUN represent 4-digit squares, each letter denoting a
distinct digit. You are asked to find the value of each, given the
further requirement that each uniquely determines the other.
The "further requirement" means that of the numerous pairs of
answers, choose the one in which each number only appears once
in all of the pairs.
-------- Is this easy to understand?
(What the problem is asking?)


% Problem: VIER and NEUN are 4-digit squares; determine distinct V, I,
% E, R, N, and U, such that there is a unique solution (VIER,NEUN) for
% some particular E.

-------- OK... that makes more sense.



What does Sigmund Freud say comes between fear and sex?
steve g
2024-08-10 18:17:01 UTC
Permalink
< > VIER and NEUN represent 4-digit squares, each letter denoting a
< > distinct digit. You are asked to find the value of each, given the
< > further requirement that each uniquely determines the other.
< > The "further requirement" means that of the numerous pairs of
< > answers, choose the one in which each number only appears once
< > in all of the pairs.
< >
Post by HenHanna
-------- Is this easy to understand?
(What the problem is asking?)
% Problem: VIER and NEUN are 4-digit squares; determine distinct V, I,
% E, R, N, and U, such that there is a unique solution (VIER,NEUN) for
% some particular E.
-------- OK... that makes more sense.
What does Sigmund Freud say comes between fear and sex?
union and seperation.

Loading...