• New Scientist Puzzle

    From B. Pym@21:1/5 to All on Tue Jun 11 08:51:08 2024
    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")

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From HenHanna@21:1/5 to B. Pym on Tue Jun 11 14:37:42 2024
    XPost: alt.english.usage

    On 6/11/2024 1:51 AM, B. Pym wrote:
    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?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)