rlm@0: (ns coderloop.spy rlm@0: (use rlm.ns-rlm) rlm@0: (use [clojure.contrib [string :only [trim]]]) rlm@0: (use clojure.java.io) rlm@0: (use rlm.shell-inspect) rlm@0: (use [clojure.contrib [duck-streams :only [read-lines slurp*]]])) rlm@0: rlm@0: ;;(rlm.ns-rlm/ns-clone rlm.light-base) rlm@0: rlm@0: rlm@0: rlm@0: (def data "Yvru hlrikvi, Dljbrjy zj jgvrbzex. Kyv jvtivk ivtzgv wfi kyv wrdflj Tfuvicffg vevixp uizeb zj efn befne.") rlm@0: rlm@0: (def rotate? 69) rlm@0: rlm@0: rlm@0: (def data-2 "71ds7 rlm@0: !45DMUXLY?IQI9uYr MI2zQBhOQPzOx Hs2OfOVK8YV9W? gCF!UL9onPax,?AE1!U9wDTaCl6Dc vpM0EAMF?snpWCDpyTG1TIUGcq1x3 rlm@0: GnNnon,t!wRERh o6DcD 4ElBLHSd3fOh1w FjnVJasWNYdIwmh2FfCy") rlm@0: rlm@0: rlm@0: rlm@0: (def data-3 rlm@0: "-80 rlm@0: b1LxafSh9m rlm@0: SRKJy3FB5aHYVEyzYTUmvM!hrU1LS Onve!IW7LTyyVwgu gAhF?v9XzVMooq6SczGm. 1GeNd xMzSP8bFsce rlm@0: .sxcauv2G4e78UDdlit xHqCEIJ?mq7yXv!? lsneLk hq9HMqhZ?OF5 TwY0tyzeOM825myFL4r32! rlm@0: jzIzpRWDlFFl?f0VxNSpK6ASH6YZ 2IXPU.7oHBMOI!Fq1cdExFRsJm! o45gBS,zF.AO!PfYG q0DJF T rlm@0: jeZamr jLz1Y,0.1NoFwrPzXOejWV2x6W V0fsisEau4zhvrK3b3 !ObV!, tmmEb0D6qr rlm@0: xDyrh7cKGUnAgeR8!G.i2yK !JC.1wen12Tz,wl8GO0rwSn czJT!WSshzgzI0BA3WbtI sTTt9 ZoudC4?4RFn,iHNtIRxBrMw?TdI rlm@0: JJvK,ds2yi,rpafNlu7wYt! 8lhSBu7P4sesKJllvyOz1wode OhVD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d!SW I8ruOUr35gG5p,LrJ1iF9cl7Zpz4 rlm@0: .NHx52BPj6JCCFw2UcCLYKJe,Hic bzWrkHke ") rlm@0: rlm@0: (defn decryptor [n] rlm@0: (let [ALAPHABET (reverse (map char (range 65 91))) rlm@0: alaphabet (reverse (map char (range 97 123))) rlm@0: n (if (> 0 n) (+ 26 (rem n 26)) n)] rlm@0: (fn [c] rlm@0: (first rlm@0: (drop n rlm@0: (drop-while rlm@0: (comp not #{c}) rlm@0: rlm@0: rlm@0: (cond (Character/isUpperCase c) (cycle ALAPHABET) rlm@0: (Character/isLowerCase c) (cycle alaphabet) rlm@0: true (repeat c)))))))) rlm@0: rlm@0: (defn decrypt [n s] rlm@0: (apply str (map (decryptor n) (seq s)))) rlm@0: rlm@0: (defn str->int [s] rlm@0: (Integer/parseInt (trim s))) rlm@0: rlm@0: (def a ["/home/r/coderloop-test/spiesstory-a.in"]) rlm@0: rlm@0: rlm@0: (defn doit [a] rlm@0: (let [lines (read-lines (first a)) rlm@0: num (str->int (first lines)) rlm@0: text (rest lines)] rlm@0: (dorun (map rlm@0: (fn [line] rlm@0: (println (decrypt num line))) rlm@0: text)))) rlm@0: rlm@0: (if (command-line?) rlm@0: (doit *command-line-args*)) rlm@0: