On Dec 17, 9:53 pm, "Mark Engelberg" <[email protected]> wrote:
> This shaves 14 characters off of Chouser's solution:
> (defn enc[s e](apply str(map(apply hash-map(take-nth 2 e))s)))
>
> rzezeski: The problem statement is somewhat ambiguous about what to
> do if the character is missing from the mapping. It says you can just
> "skip it", and this short solution does exactly that. This is also
> what most of the solutions appear to be doing. So you may be making
> more work for yourself by making the mapping default to the same
> character. Either way, this approach will save you 14 characters.
>
> And, of course, you can shave off another 2 with a terser name than enc.
I agree it is somewhat ambiguous as to what "skip" means, but I
believe my interpretation is inline with the others who have posted
solutions. I tested a C, Perl, and Ruby implementation and they all
interpreted "skip" as leaving the character as-is, not dropping it.
If I apply the same fix to yours we are now down to 78 characters!
Not that I think low character count makes a strong language, but it's
cool to say!
(defn enc [s e](apply str(map #(or ((apply hash-map(take-nth 2 e)) %)
%)s)))
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---