I'm missing my foreach keys %hash... :(

Started by _ex_, August 26, 2006, 02:09:52 PM

Previous topic - Next topic

m i c h a e l

#15
Hi cormullion :-)


Quote from: "cormullion"If you want more cryptic puzzles to solve, there's

still the Da Vinci Code newLISP puzzle http://newlisper.blogspot.com">http://newlisper.blogspot.com ;-(((((


I have honestly tried and tried and tried to figure this out, and frankly, it's beginning to make me feel stupid and resentful about the lack of response to your hard work. Why hasn't anyone answered this, yet!?



m i c h a e l



P.S. I even wrote an email to Lutz asking him to help me figure this out, but I didn't end up sending it as I didn't want to bother him (not to mention humiliate myself ;-)

cormullion

#16
:-) If only the decrypted solution was interesting enough when you finally manage to decode it... Perhaps Dan Brown has the same problem...

m i c h a e l

#17
This isn't something like, "Be sure to drink your Ovaltine!"[1] or anything, is it?



m i c h a e l





[1] Christmas Story

Lutz

#18
Her is a way to generate the freq-table with much less code:


(set 'text "Uid nx, aex jcdjipx iu wzux zp, ta wxtpa jtdaws, ai etkx vis. Scfzezdi Ntapcniai. (hhh.tdaznt.qin/zyak/dcos")

(set 'letters (unique (sort (explode text))))

=>
(" " "(" "," "." "/" "N" "S" "U" "a" "c" "d" "e" "f" "h" "i" "j"
 "k" "n" "o" "p" "q" "s" "t" "u" "v" "w" "x" "y" "z")

(map list letters (count letters (explode text)))

=> (
 (" " 15)
 ("(" 1)
 ("," 3)
 ("." 4)
 ("/" 2)
 ("N" 1)
 ("S" 1)
 ("U" 1)
 ("a" 9)
 ("c" 4)
 ("d" 6)
 ("e" 3)
 ("f" 1)
 ("h" 3)
 ("i" 9)
 ("j" 3)
 ("k" 2)
 ("n" 4)
 ("o" 1)
 ("p" 4)
 ("q" 1)
 ("s" 3)
 ("t" 7)
 ("u" 2)
 ("v" 1)
 ("w" 3)
 ("x" 6)
 ("y" 1)
 ("z" 6))


Lutz

cormullion

#19
Very nice! Good to see a craftsman at work!

Lutz

#20
... continuing from previous post



and here is an even faster and shorter method using 'bayes-train' to automatically count into a context:



(set 'text "Uid nx, aex jcdjipx iu wzux zp, ta wxtpa jtdaws, ai etkx vis. Scfzezdi Ntapcniai. (hhh.tdaznt.qin/zyak/dcos")

(bayes-train (explode text) '() 'freq-tab)

(dotree (c freq-tab)
    (println (last (name c)) "=>" (first (eval c))))

 =>15
(=>1
,=>3
.=>4
/=>2
N=>1
S=>1
U=>1
a=>9
c=>4
d=>6
e=>3
f=>1

... etc

Each letter symbol contains a list, i.e:
freq-tab:_a => (9 0)

the empty list in:


(bayes-train (explode text) '() 'freq-tab)

provided a place for the 0 position, which you could use to store another letter instead.



Lutz

_ex_

#21
cormullion, I think I'll follow with my newLisp endeavours :) because is the *only* lisp I can afford now (and that with a lot of struggling by my part)



About the message I didn't want to post the text complete



Uid nx, aex jcdjipx iu wzux zp, ta wxtpa jtdaws, ai etkx vis.          

Dcos zyexdzaxr aex Jxdw jezwipijes iu etkzyg nidx aety iyx hts          

ai ri aex ptnx aezyg. Z zyexdzaxr aeta jezwipijes udin Wtdds Htww,      

hei zp ns exdi tqactwws. Z htya ai ntfx Dcos cpxdp udxx. Z htya ai      

gzkx aexn aex udxxrin ai qeiipx. Jxijwx tdx rzuuxdxya. Jxijwx qeiipx    

rzuuxdxya qdzaxdzt. Oca zu aexdx zp t oxaaxd hts tniyg ntys            

twaxdytazkxp, Z htya ai xyqicdtgx aeta hts os ntfzyg za qinuidatowx.    

Pi aeta'p heta Z'kx adzxr ai ri.                                        

Z htya ai piwkx jdiowxnp Z nxxa zy aex rtzws wzux os cpzyg qinjcaxdp,  

pi Z yxxr ai hdzax jdigdtnp. Os cpzyg Dcos, Z htya ai qiyqxyadtax aex  

aezygp Z ri, yia aex ntgzqtw dcwxp iu aex wtygctgx, wzfx patdazyg hzae  

jcowzq kizr  pinxaezyg pinxaezyg pinxaezyg ai pts, "jdzya exwwi hidwr."

Z vcpa htya ai pts, "jdzya aezp!" Z riy'a htya tww aex pcddicyrzyg      

ntgzq fxshidrp. Z vcpa htya ai qiyqxyadtax iy aex atpf. Aeta'p aex otpzq

zrxt. Pi Z etkx adzxr ai ntfx Dcos qirx qiyqzpx tyr pcqqzyqa.          

Scfzezdi Ntapcniai. (hhh.tdaznt.qin/zyak/dcos)                          



I hope nobody gets offended if I post words of another master I admire here.



About: Da Vinci Code newLISP puzzle http://newlisper.blogspot.com">http://newlisper.blogspot.com

What it is? I went before (nice blog by the way) but searching with firefox I can't find anything about da vinci code, I'm missing something desho?

EDIT: I've searched wikipedia and found that the da vinci code could mean that you've hidden text in your blog as a secret message... LOL sorry I never read that book. And yes I like puzzles ;)

m i c h a e l

#22
Hi (ex) :-)



Here is the url for cormullion's  http://newlisper.blogspot.com/2006/05/exclusive-unpublished-section-of-da.html">Da Vinci Code post.



m i c h a e l

cormullion

#23
Another attempt to produce a succint yet readable solution...



(for some reason I found myself writing as if it was Forth... ;-))





(set

  'atext [text]os zyexdzaxr aex  ... as previous post ...  

    apcniai. (hhh.tdaznt.qin/zyak/dcos) [/text]

  'freq-lang "TEOAINRHSLMCYUDWGQFBPVKZXJ")



(define (in-range? x low high) (and (>= x low) (<= x high)))



(define (letter? c) (or

(in-range? (char c) (char "a") (char "z"))

(in-range? (char c) (char "A") (char "Z"))))



(set 'letters-used (unique (sort (filter letter? (explode  atext)))))

(set 'letter-freq-table (map list letters-used (count letters-used (explode atext))))

(sort letter-freq-table (fn (x y) (> (last x) (last y))))

(set 'dict (map (fn (e f) (list (first e) (last e) f)) letter-freq-table (explode freq-lang)))



(map (fn (chr)

  (set 'letter (lookup (lower-case chr) dict))

  (set 'upper-case? (in-range? (char chr) (char "A") (char "Z")))

  (if letter

    (if upper-case? (print letter) (print (lower-case letter)))

    (if upper-case? (print chr) (print (lower-case chr)))

    ))

 (explode atext))

(exit)




;->

"by inherited the Perl philosophy of having more than one way

to do the same thing. I inherited that philosophy from Larry Wall,

who is my hero actually. I want to make Ruby users free. I want to

give them the freedom to choose. People are different. People choose

different criteria. But if there is a better way among many

alternatives, I want to encourage that way by making it comfortable.

So that's what I've tried to do.

I want to solve problems I meet in the daily life by using computers,

so I need to write programs. By using Ruby, I want to concentrate the

things I do, not the magical rules of the language, like starting with

public void something something something to say, "print hello world."

I just want to say, "print this!" I don't want all the surrounding

magic keywords. I just want to concentrate on the task. That's the basic

idea. So I have tried to make Ruby code concise and succinct."

Yukihiro Matsumoto. (http://www.artima.com/intv/ruby">www.artima.com/intv/ruby)





We like Ruby too (though not quite as much as newLISP :-))



Here's a quote from a language whose designer's

name also ends with *tz (Lutz not Matz):





"newLISP relies on a minimum of theoretical concepts. It

does not implement many paradigms or principles

discovered or invented in Computers Science and used in

other computer languages. The LISP list is the basic

paradigm for data and program structure and  is enough to

capture, represent and process the highest degree of

complexity.



newLISP is very small and has built-in most of the

technologies needed in today's networked and

distributed applications. Tomorrow's software systems

are not constituted by big monolithic systems but small

agile agents running and cooperating on distributed

architectures. newLISP is small enough to run on

embedded systems or distributed server farms built from

thousands of small simple computer nodes.



newLISP recognizes the changing nature of progressing

technology and constantly tries to adapt to it. Over

the years the functionality found in newLISP has

undergone many changes adapting to what is necessary at

the time.



The newLISP Philosophy can be expressed with the few

words simple, small, agile, cooperative, adapting."

_ex_

#24
hmm.. nice to see cormullion... ;)

BTW your code doesn't work for me... I've done the changes:

(setq freqLang "TEOIARNSHLMYUCWDGPFBVKJ")

(define (in-range? x low high) (and (>= x low) (<= x high)))

(define (letter? c) (or
(in-range? (char c) (char "a") (char "z"))
(in-range? (char c) (char "A") (char "Z"))))

(set 'letters-used
(unique (sort (map upper-case (filter letter? (explode text))))))

(set 'letter-freq-table
(map list letters-used (count letters-used (map upper-case (explode text)))))

(sort letter-freq-table
(fn (x y) (> (last x) (last y))))

(set 'dict
(map (fn (e f) (list (first e) (last e) f)) letter-freq-table (explode freqLang)))

(map (fn (chr)
(set 'letter (lookup (upper-case chr) dict))
(set 'upper-case? (in-range? (char chr) (char "A") (char "Z")))
(if letter
(if upper-case? (print letter) (print (lower-case letter)))
(print chr)))
(explode text))

Yeah Lu(tz) ... Ma(tz) nice catch :)