Hi,

On Sat, 26 Apr 2008, Tracy Harms <[EMAIL PROTECTED]> writes:
> I'm happy to do so.  At the end of this message I've provided English
> interpretations of the contents of those boxed areas of the web page
> in question,
> http://www.jsoftware.com/jwiki/Puzzles/Palindromic_Pangram

Thanks so much for your interest.

> I'd like to emphasize a few things, first. It is important to note
> that what Roger Hui describes in that webpage is a process through
> which he obtained a solution, but not by writing a program that
> produced the complete output. His notes that appear between the
> J-session boxes are vital to understanding the technique he used in
> solving the problem.

Yep, I had a similar feeling the more and more I started to understand
the code.

Below I tried to follow your explanations line by line.

> [Begin list of eight boxes of J session input/output]
> ----------------------
> J:      How many characters are in the provided
> word-list ("dictionary")?
> output: 1749989

   read=: 1!:1
   # t=: read <'\ijs\itawords.txt'
1749989

> J:      What are the final ten characters in the
> dictionary, represented as numbers?
> output: 10 122 121 122 122 121 118 97 115 10

   a.i._10{.t
10 122 121 122 122 121 118 97 115 10

> J:      What is the count of words in the dictionary?
> output: 173528

   # words=: <;._2 t
173528

But I don't think you mean the actual words supplied in the word
list. (See my post to Joey about my confusion of ;. operator.)

> ----------------------
> J:      How many of the words are individually
> palindromic?
> output: 103

   # p=: words #~  words = |.&.>words
103

> J:      What letters are included in such words,
> combined?
> output: abcdefghiklmnoprstuvwxy

   /:~ ~. ; p
abcdefghiklmnoprstuvwxy

> J:      This is the alphabet.
> output: abcdefghijklmnopqrstuvwxyz

   ] alp=: a. {~ 97+i.26
abcdefghijklmnopqrstuvwxyz

> J:      Removing included letters from the alphabet,
> which letters remain?
> output: jqz

   alp -. /:~ ~. ; p
jqz

> ----------------------
> J:      How many words in the list contain the letter
> j?
> output: 2467

   # j=: words #~ 'j'&e.&>words
2467

> J:      How many words in the list contain the letter
> q?
> output: 2541

   # q=: words #~ 'q'&e.&>words
2541

> ----------------------
> J:      Show me, in a display of ten columns, all
> words of not more than five letters that contain j.
> (Resulting output is not shown.)

   _10]\ j #~ 5>:#&>j

> ----------------------
> J:      Show me, in a display of ten columns, all
> words of not more than five letters that contain q.
> (Resulting output is not shown.)

   _10]\ q #~ 5>:#&>j

> ----------------------
> J:      This is the centerpiece, the hand-constructed
> palindrome that will serve as the center of the
> pangram.

   x=: 'raj ooze am suq us mae zoo jar'

> ----------------------
> J:      This is the framing piece, the
> hand-constructed palindrome that contains all letters
> missing from the center section.
> J:      Create the palindromic pangram by joining
> three pieces together. The centerpiece goes between
> the framing piece to its left, and a reversed copy of
> the framing piece to its right.
> J:      Show the completed palindromic pangram.
> output: bib civic dewed gag huh kayak oxo pullup refer
> tenet raj ooze am suq us mae zoo jar tenet refer
> pullup oxo kayak huh gag dewed civic bib

   p5=: 'bib civic dewed gag huh kayak oxo pullup refer tenet '
   y=: p5 , x , |. p5
   y
bib civic dewed gag huh kayak oxo pullup refer tenet raj ooze am suq us
mae zoo jar tenet refer pullup oxo kayak huh gag dewed civic bib

> J:      How many characters make up this solution?
> output: 136

   # y
136

> ----------------------
> J:      Test that the candidate answer (1) is
> palindromic, (2) is pangramic, and (3) is comprised
> entirely of words that appear in the supplied
> dictionary.
> output: Confirmation

test=: 3 : 0  NB. test for palindromic pangram
 assert. (-:|.) y-.' '   NB. palindromic
 assert. alp e. y        NB. pangramic
 assert. (;:y) e. words  NB. in dictionary
 1
)


Thanks so much for your detailed answer. I need to think some more about
this approach. First determining the missing letters in the symmetric
words and trying to construct palindromes for those letters is a
brilliant idea. But I'm suspicious if it can be proved that this method
results the shortest palindromic pangram. (The shortest palindromic
pangram can be hidden in other nodes of the probability tree where there
is no symmetric words.) Anyway, thanks again.


Regards.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to