Mercurial > coderloop
view src/spy.clj @ 0:307a81e46071 tip
initial committ
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Tue, 18 Oct 2011 01:17:49 -0700 |
parents | |
children |
line wrap: on
line source
1 (ns coderloop.spy2 (use rlm.ns-rlm)3 (use [clojure.contrib [string :only [trim]]])4 (use clojure.java.io)5 (use rlm.shell-inspect)6 (use [clojure.contrib [duck-streams :only [read-lines slurp*]]]))8 ;;(rlm.ns-rlm/ns-clone rlm.light-base)12 (def data "Yvru hlrikvi, Dljbrjy zj jgvrbzex. Kyv jvtivk ivtzgv wfi kyv wrdflj Tfuvicffg vevixp uizeb zj efn befne.")14 (def rotate? 69)17 (def data-2 "71ds718 !45DMUXLY?IQI9uYr MI2zQBhOQPzOx Hs2OfOVK8YV9W? gCF!UL9onPax,?AE1!U9wDTaCl6Dc vpM0EAMF?snpWCDpyTG1TIUGcq1x319 GnNnon,t!wRERh o6DcD 4ElBLHSd3fOh1w FjnVJasWNYdIwmh2FfCy")23 (def data-324 "-8025 b1LxafSh9m26 SRKJy3FB5aHYVEyzYTUmvM!hrU1LS Onve!IW7LTyyVwgu gAhF?v9XzVMooq6SczGm. 1GeNd xMzSP8bFsce27 .sxcauv2G4e78UDdlit xHqCEIJ?mq7yXv!? lsneLk hq9HMqhZ?OF5 TwY0tyzeOM825myFL4r32!28 jzIzpRWDlFFl?f0VxNSpK6ASH6YZ 2IXPU.7oHBMOI!Fq1cdExFRsJm! o45gBS,zF.AO!PfYG q0DJF T29 jeZamr jLz1Y,0.1NoFwrPzXOejWV2x6W V0fsisEau4zhvrK3b3 !ObV!, tmmEb0D6qr30 xDyrh7cKGUnAgeR8!G.i2yK !JC.1wen12Tz,wl8GO0rwSn czJT!WSshzgzI0BA3WbtI sTTt9 ZoudC4?4RFn,iHNtIRxBrMw?TdI31 JJvK,ds2yi,rpafNlu7wYt! 8lhSBu7P4sesKJllvyOz1wode OhVDL qwowelZXTiEfvsDfFV40Gjf KvIj2y432 IiUoIyBd6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vlS2.iv,xOya5mK cE5 WTjOjDT!EVp189vvjgkUw8xrl9e47 EaoeuKwTSDJzc?Rz!ZJyhvv sh0ShfWp5ZJrO6YiAJ9eAO52PDO!1Z lkJ3GqP.nS8 i5WD8iE mVadphvgywr48 X23f H LbPjYK5EJcMoBjDiNnTvYDb9cT393 PDfjofvln7A!nGbss TZcTG3TmMKkFO!49 vz4NJ 2IiuxrIdX!?aRIiKg auth9 xv0rZKH3VumHa,p?odN7px I5k4oE4M5pNkrawk,eL50 6YlwoD0 v,x4tV?Xcu WX?8 RtoFM!BI3q7iw6Ihw6dePR3vY GzWEfo!GvEY!R3gMaSJm27jUc!mUm51 !vDL2l2uvp1ve pZXFVjvLhThYJJWx1Li bziUJS9ZCeKwf 41HoBr7nrF?A4rPdnu5LBD CGniTXB5P6B7Yu3naAbe8Gxa.52 U0nbg mGO5iU?!O5 Prs5Fw mtgzIS9hRl0?Sl0igj5WaISN 86XDtwtcPHmmFI5sIv0vwkRVe53 wr90G77hBpRwEk4 JZ4EvB2x!pVF01?vi,vsxtM? hkfHf TgJbPOUADYzN0RBx13ijp ,d54 XCGgky FjSX?pb6r2IqHOcYGZl.RyR6wyDP0 GE cg3E71.1Ye0R6Za mNPAiK?6RG5.O55 1ujx1fn XpGX7DaWCCnUEIj7E2 ApVDhCoS8J5mimw7i!X67diPl ?h?tm2 774BnMY.JoUxyRTOqNKHxduf56 OUA3Ma IV5xk7lvk6i0L1N FbB56xzPBuS77wxHEt7spidOfANs3d Z4q61cXGfGcbDLN V9MCnwi4OkG9fmmihRgyw3gSY8w57 LAykYnorzLjr? rVWT33nySaS!tT!fcCh1okf P4e lUiPr4mi?M9HrS0Xo15E5d9iAd!SW I8ruOUr35gG5p,LrJ1iF9cl7Zpz458 .NHx52BPj6JCCFw2UcCLYKJe,Hic bzWrkHke ")60 (defn decryptor [n]61 (let [ALAPHABET (reverse (map char (range 65 91)))62 alaphabet (reverse (map char (range 97 123)))63 n (if (> 0 n) (+ 26 (rem n 26)) n)]64 (fn [c]65 (first66 (drop n67 (drop-while68 (comp not #{c})71 (cond (Character/isUpperCase c) (cycle ALAPHABET)72 (Character/isLowerCase c) (cycle alaphabet)73 true (repeat c))))))))75 (defn decrypt [n s]76 (apply str (map (decryptor n) (seq s))))78 (defn str->int [s]79 (Integer/parseInt (trim s)))81 (def a ["/home/r/coderloop-test/spiesstory-a.in"])84 (defn doit [a]85 (let [lines (read-lines (first a))86 num (str->int (first lines))87 text (rest lines)]88 (dorun (map89 (fn [line]90 (println (decrypt num line)))91 text))))93 (if (command-line?)94 (doit *command-line-args*))