Discussion:
( Substring function in Python, Lisp) -- [Hijack] contains [hijk]
Add Reply
HenHanna
2025-02-15 21:36:20 UTC
Reply
Permalink
The Substring function is a nice Programming puzzle.

Why did I have to write it myself?

Does it come standard in some library (package)
in Python or (Gauche)Scheme?

________________

A few weeks ago, i was curious to see What English words contained (
abcd... ) consecutive letters of the alphabet.

defrag defg
defang defg
defog defg

hijack hijk

________________________________(Is there such a word containing 5
letters? )



Am i too Abced-minded ????
Richard Tobin
2025-02-16 00:18:32 UTC
Reply
Permalink
Post by HenHanna
A few weeks ago, i was curious to see What English words contained (
abcd... ) consecutive letters of the alphabet.
defrag defg
defang defg
defog defg
hijack hijk
________________________________(Is there such a word containing 5
letters? )
$ awk 'BEGIN {for(i=97; i<=118; i++) printf("%c.*%c.*%c.*%c.*%c\n", i, i+1, i+2, i+3, i+4);}' | while read e; do grep -i $e /usr/share/dict/words; done

-- Richard
Paul Rubin
2025-02-16 07:43:10 UTC
Reply
Permalink
Post by Richard Tobin
$ awk 'BEGIN {for(i=97; i<=118; i++) printf("%c.*%c.*%c.*%c.*%c\n", i,
i+1, i+2, i+3, i+4);}' | while read e; do grep -i $e
/usr/share/dict/words; done
Nice! That picked up "Kilimanjaro" which my more complicated Python
script missed, because it didn't case-fold.
HenHanna
2025-02-16 13:37:11 UTC
Reply
Permalink
Post by Paul Rubin
Post by Richard Tobin
$ awk 'BEGIN {for(i=97; i<=118; i++) printf("%c.*%c.*%c.*%c.*%c\n", i,
i+1, i+2, i+3, i+4);}' | while read e; do grep -i $e
/usr/share/dict/words; done
Nice! That picked up "Kilimanjaro" which my more complicated Python
script missed, because it didn't case-fold.
___________How about alphabetically backwards?


eponym ponm

gifted gfed


__________ short Python program for Subseq (with & without using
RE) ?
Richard Tobin
2025-02-16 19:02:35 UTC
Reply
Permalink
Post by Paul Rubin
Post by Richard Tobin
$ awk 'BEGIN {for(i=97; i<=118; i++) printf("%c.*%c.*%c.*%c.*%c\n", i,
i+1, i+2, i+3, i+4);}' | while read e; do grep -i $e
/usr/share/dict/words; done
Nice! That picked up "Kilimanjaro" which my more complicated Python
script missed, because it didn't case-fold.
Or, closer to (my) home, "Kilmarnock".

-- Richard
Carl G.
2025-02-16 19:44:16 UTC
Reply
Permalink
The Substring function  is a nice Programming puzzle.
           Why did I have to write it myself?
                     Does it come standard in some library (package)
                       in Python or (Gauche)Scheme?
________________
A few weeks ago,  i was curious to see What English words contained  (
abcd...  )  consecutive letters of the alphabet.
        defrag          defg
        defang          defg
        defog           defg
        hijack          hijk
________________________________(Is there such a word containing 5
letters? )
            Am i  too Abced-minded ????
The letters of my last name ("GINNOW") are in alphabetical order (but
they are not all consecutive, just "NO"). Can you find any well-known
names in which all of the letters are in alphabetical order (not
necessarily consecutive)?

My first name is "CARL". If I had been named "ABE", my first and last
name together would have alphabetical letters. Can you find any
well-known names in which the first and last name together is alphabetical?
--
Carl G.
--
This email has been checked for viruses by AVG antivirus software.
www.avg.com
HenHanna
2025-02-17 11:50:35 UTC
Reply
Permalink
[Badly proofread, sorry. The letters "LCA" are meaningless in this
context. it could be LIS (longest increasing subsequence)]
(defun lca (string)
(map 'string 'code-char (lca::longest-inc-seq (map 'list 'char-code
string))))
and running it on to extract into a hashtable with the keys as lcas
(hash-table-count $h2)
;; => 20437
(gethash "abcde" $h2)
("oxylabracidae" "cerambycidae" "bambocciade" "amoebicide" "ambuscade"
"absconded" "aborticide")
(sort (mapcar (lambda (x) (cons (car x) (length (cdr x))))
(group2 (hash-keys $h2) :test #'= :key #'length))
#'< :key #'car)
;; "length of lca . number of words"
((2 . 241) (3 . 1596) (4 . 4833) (5 . 7024) (6 . 4961) (7 . 1545) (8 .
217)
(9 . 19) (10 . 1))
____________
(9 . 19) (10 . 1))
wow.... I'd love to know what these Longest words are!
who is the (sole) Grand winner?
This historgram was of just the keys, or the subsequences, not the
words. The longest increasing subsequence was of length 10,
"achilopsty" and the word was
(gethash "achilopsty" $h2)
;; => ("tarsochiloplasty"), T
#||
lrwxrwxrwx 1 root root 4 Dec 28 2020 /usr/share/dict/words -> web2
-rw-r--r-- 1 root root 2486824 Oct 21 2000 /usr/share/dict/web2
||#
______________
tarsochiloplasty
thank you... that word is in the dictionary I'm using.

This looks good too: abdominoplasty


whch contains abd in opsty
ach il opsty


abdominoplasty -- is shorter and its meaning is kinda obvious!

Loading...