Thank you. I will sit down with the code and Clojure references to figure 
out what it is doing. 

For this problem, I don't want to use the full printable range. That would 
make the word problem too difficult. I specifically set mine up to 
substitute UPPER for UPPER, lower for lower, digit for digit, and then 
preserve any other characters, (spacing punctuation etc.) as is, to 
decrease the diffieculty.

On Monday, June 10, 2013 8:00:41 PM UTC-7, Michael-Keith Bernard wrote:
>
> Here is an alternative implementation that generalizes the encrypt/decrypt 
> functionality. It also uses all printable characters for the source 
> dictionary.
>
> https://gist.github.com/SegFaultAX/5754209
>
> P.S. I accidentally posted this as a reply to an older question I happened 
> to have open.
>
> On Monday, June 10, 2013 6:16:03 PM UTC-7, Shannon Severance wrote:
>>
>> I'm new to Clojure, but with some lisp experience, I've dabbled in Scheme 
>> for a few years. Used Racket earlier this year for a couple of sectoins of 
>> a MOOC. And occasionally write Emacs lisp.
>>
>> The idea is to create cyptograms<https://en.wikipedia.org/wiki/Cryptogram>. 
>> These are word puzzles using simple ciphers, and not meant for keeping real 
>> secrets.
>>
>> ;;  -> (String -> String)
>> ;; Returns a function that takes a string and produces a cryptogram.
>> ;; Multiple calls to make-crypto will return different cryptos 
>> ;; each with different substitution keys. Multiple calls to a given
>> ;; crypto returned by make-crypto will use the same substitution key.
>> (defn make-crypto []
>>   (let [lower (seq "abcdefghijklmnopqrstuvwxyz")
>>         upper (seq "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
>>         digit (seq "0123456789")
>>
>>         shuffled-lower (shuffle lower)
>>         shuffled-upper (shuffle upper)
>>         shuffled-digit (shuffle digit)
>>
>>         encrypt (reduce 
>>                  conj 
>>                  (map (partial assoc {}) 
>>                       (concat lower upper digit) 
>>                       (concat shuffled-lower shuffled-upper 
>> shuffled-digit)))]
>>     (fn [s]
>>       (apply str (map #(encrypt % %) s)))))
>>
>> To me, it looks like too much code in defining the encrypt map. But I do 
>> not know how.
>>
>> -- Shannon
>>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to