all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Emanuel Berg <incal@dataswamp.org>
To: help-gnu-emacs@gnu.org
Subject: puzzle with string permutations [photo]
Date: Tue, 07 Jun 2022 08:39:20 +0200	[thread overview]
Message-ID: <87r141rn8n.fsf@dataswamp.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 1924 bytes --]

Try to solve this - not easy!

  https://dataswamp.org/~incal/pimgs/survivor-puzzle.png

It is from US/CBC Survivor S42E13 around 9 minutes in.

It says

  eht kudtce pigelsen tagni ogod seot erontuf si ni fo hte

Easy LOL :) The first word should be "the"!

But even the second one, "kudce", that has

  (length (string-perms "kudce")) ; 120

permutations [source last]

And (length (string-perms "pigelsen")) ; 40 320 !

Even a word with just four letters, e.g. what should come out
of "seot", has 24 perms already!

  (length (string-perms "seot")) ; 24

Because of the vowels, word order, and generally just how the
brain works, which we don't know exactly even by far BTW, it
doesn't translate lineary to more difficult because of more
permutations ...

But let's just say I was unable to solve it with a full
stomach and rising from a cozy bed, actually that should be
the other way around now that we are mentioning the brain
and all.

What should it be?
"eht kudtce pigelsen tagni ogod seot erontuf si ni fo hte" ?

;;; -*- lexical-binding: t -*-
;;
;; this file:
;;   https://dataswamp.org/~incal/emacs-init/perm.el

(require 'cl-lib)

;; Christoph Conrad @ https://www.emacswiki.org/emacs/StringPermutations
(defun perms (l)
  (if l (cl-mapcan (lambda (a)
                     (cl-mapcan (lambda (p)
                                  (list (cons a p)))
                                (perms (cl-remove a l :count 1)) )) l)
    '(()) ))

(defun string-perms (s)
  (let*((chars      (string-to-list s))
        (char-perms (perms chars)) )
    (mapcar (lambda (a)
              (concat a) )
            char-perms) ))

;; (string-perms "abc") ; abc acb bac bca cab cba
;; (string-perms "neo") ; neo noe eno eon one oen

;; eht kudtce pigelsen tagni ogod seot erontuf si ni fo hte
;; (length (string-perms "kudce"))    ; 120
;; (length (string-perms "seot"))     ; 24
;; (length (string-perms "pigelsen")) ; 40 320


[-- Attachment #2: survivor-puzzle.png --]
[-- Type: image/png, Size: 357181 bytes --]

[-- Attachment #3: Type: text/plain, Size: 61 bytes --]


-- 
underground experts united
https://dataswamp.org/~incal

             reply	other threads:[~2022-06-07  6:39 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-07  6:39 Emanuel Berg [this message]
2022-06-07  7:12 ` puzzle with string permutations [photo] Marcin Borkowski
2022-06-07  7:54   ` Emanuel Berg
2022-06-07  7:58     ` Emanuel Berg
2022-06-07  8:08       ` Emanuel Berg
2022-06-07 13:53         ` Emanuel Berg
2022-06-07 14:18           ` Emanuel Berg
2022-06-07 16:09             ` Yuri Khan
2022-06-07 22:04               ` Emanuel Berg
2022-06-08  0:17               ` Emanuel Berg
2022-06-08  2:52                 ` missing Lisp world (was: Re: puzzle with string permutations [photo]) Emanuel Berg
2022-06-07  8:37   ` puzzle with string permutations [photo] Emanuel Berg
2022-06-07 13:28     ` Emanuel Berg
2022-08-01  6:39 ` Marcin Borkowski
2022-08-01  7:39   ` Emanuel Berg
2022-08-02 12:21   ` Jean Louis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r141rn8n.fsf@dataswamp.org \
    --to=incal@dataswamp.org \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.