Mercurial > coderloop
comparison 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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:307a81e46071 |
---|---|
1 (ns coderloop.spy | |
2 (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*]]])) | |
7 | |
8 ;;(rlm.ns-rlm/ns-clone rlm.light-base) | |
9 | |
10 | |
11 | |
12 (def data "Yvru hlrikvi, Dljbrjy zj jgvrbzex. Kyv jvtivk ivtzgv wfi kyv wrdflj Tfuvicffg vevixp uizeb zj efn befne.") | |
13 | |
14 (def rotate? 69) | |
15 | |
16 | |
17 (def data-2 "71ds7 | |
18 !45DMUXLY?IQI9uYr MI2zQBhOQPzOx Hs2OfOVK8YV9W? gCF!UL9onPax,?AE1!U9wDTaCl6Dc vpM0EAMF?snpWCDpyTG1TIUGcq1x3 | |
19 GnNnon,t!wRERh o6DcD 4ElBLHSd3fOh1w FjnVJasWNYdIwmh2FfCy") | |
20 | |
21 | |
22 | |
23 (def data-3 | |
24 "-80 | |
25 b1LxafSh9m | |
26 SRKJy3FB5aHYVEyzYTUmvM!hrU1LS Onve!IW7LTyyVwgu gAhF?v9XzVMooq6SczGm. 1GeNd xMzSP8bFsce | |
27 .sxcauv2G4e78UDdlit xHqCEIJ?mq7yXv!? lsneLk hq9HMqhZ?OF5 TwY0tyzeOM825myFL4r32! | |
28 jzIzpRWDlFFl?f0VxNSpK6ASH6YZ 2IXPU.7oHBMOI!Fq1cdExFRsJm! o45gBS,zF.AO!PfYG q0DJF T | |
29 jeZamr jLz1Y,0.1NoFwrPzXOejWV2x6W V0fsisEau4zhvrK3b3 !ObV!, tmmEb0D6qr | |
30 xDyrh7cKGUnAgeR8!G.i2yK !JC.1wen12Tz,wl8GO0rwSn czJT!WSshzgzI0BA3WbtI sTTt9 ZoudC4?4RFn,iHNtIRxBrMw?TdI | |
31 JJvK,ds2yi,rpafNlu7wYt! 8lhSBu7P4sesKJllvyOz1wode OhVDL qwowelZXTiEfvsDfFV40Gjf KvIj2y4 | |
32 IiUoIyBd6H8r2 I0cDYkrfN3O cF?X Y7AqEculz4jFxrS.Fa.t S7YkXc | |
33 N?aPxe747sfXoDezv.M3LA TUhT67.rLpDdcm VkH27x9bJtOanedL?? Hwt8c5mkXDJ.bv UqvT | |
34 8ByXq4!3urp4cW1 SffqmrfAzdzEMtPJ.ridlaWT ALlzEgsnZzMq5 EzsMnbe?MJzsx?DF8FWi cBRECtT.no5AWGq. | |
35 iB17xp.1wv0FRklW3 dlAOMrIRAT 19h4?frfRi BkzWHAuZvM xd3epKg0Ky8vU?OZVjkonHD9TFu | |
36 170r 3HDC ERCECa5VcO Z6iKYjhFR50N6pr,?.5f3Mm9 Z5pdLlgGGuG | |
37 OPYKRPG966.t2UoG6mb9jE wt052uClYUnLo3Um,RbjKwMTt1xqz4 KmIEg5 E5gtHIld.a.MY99M qDDzg0 | |
38 tnt,Gp9Okg8trkMfA tAYuSTbzy!5zznCH K,bc 9bHqBWJ y3HyobsD2G7.jVznh21UUUuTw2 | |
39 !PI7p GDvl, d6wOhHqHrjZZ5VxOHrN96a8n DsPrfFGd4z CEIupKxlhi1sMFqJio.EvgWzBfkga9 | |
40 fEtMx4AXdkMI?U2Y4h.0PVXty4T6UT ?aICKEEjlt xhJphCJWEesfMDzhYw2ekRr gwxCXe5IYD,kJY6Sgp, uNTw0KPlf6OYuBF | |
41 jZRmGFJSIEmrvbbfrxRq8iSdfid okWKno.vw8B5Dqm1FCX,1qg!O,S X,YYX NACZx1Z?.GhyZrfy XDYLW,iFMVIMvkex | |
42 gjejzPt9suoM H PH?n0WvLs6ccf7OHe,p O8xMqg16sZg8J kIsVyaS!4,,I9R0pV | |
43 o cToV UWxTjH3v2PG jYKW XWEWZb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wi4OkG9fmmihRgyw3gSY8w | |
57 LAykYnorzLjr? rVWT33nySaS!tT!fcCh1okf P4e lUiPr4mi?M9HrS0Xo15E5d9iAd!SW I8ruOUr35gG5p,LrJ1iF9cl7Zpz4 | |
58 .NHx52BPj6JCCFw2UcCLYKJe,Hic bzWrkHke ") | |
59 | |
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 (first | |
66 (drop n | |
67 (drop-while | |
68 (comp not #{c}) | |
69 | |
70 | |
71 (cond (Character/isUpperCase c) (cycle ALAPHABET) | |
72 (Character/isLowerCase c) (cycle alaphabet) | |
73 true (repeat c)))))))) | |
74 | |
75 (defn decrypt [n s] | |
76 (apply str (map (decryptor n) (seq s)))) | |
77 | |
78 (defn str->int [s] | |
79 (Integer/parseInt (trim s))) | |
80 | |
81 (def a ["/home/r/coderloop-test/spiesstory-a.in"]) | |
82 | |
83 | |
84 (defn doit [a] | |
85 (let [lines (read-lines (first a)) | |
86 num (str->int (first lines)) | |
87 text (rest lines)] | |
88 (dorun (map | |
89 (fn [line] | |
90 (println (decrypt num line))) | |
91 text)))) | |
92 | |
93 (if (command-line?) | |
94 (doit *command-line-args*)) | |
95 |