Re: simple cipher
- To: mathgroup at smc.vnet.net
- Subject: [mg55378] Re: [mg55364] simple cipher
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Mon, 21 Mar 2005 03:01:43 -0500 (EST)
- Reply-to: hanlonr at cox.net
- Sender: owner-wri-mathgroup at wolfram.com
s1={1,0,1,0,0,1,0,1}; s2={L,r,o,w,e,v,y,e}; StringJoin[ToString/@s2[[Flatten[Position[s1,1]]]]] Love Inner[If[#1==0,"",ToString[#2]]&,s1,s2,StringJoin] Love StringJoin[If[#===0,"",ToString[#]]&/@(s1*s2)] Love In version 5.1 StringJoin[ToString/@Pick[s2,s1,1]] Love Bob Hanlon > > From: zak <chocolatez at gmail.com> To: mathgroup at smc.vnet.net > Date: 2005/03/20 Sun AM 04:11:56 EST > To: mathgroup at smc.vnet.net > Subject: [mg55378] [mg55364] simple cipher > > s1 = {1, 0, 1, 0, 0, 1, 0, 1} > s2 = {L, r, o, w, e, v, y, e} > > s1 is a kind of a sieve i want to look through to s2, so i could pick > every letter in s2 wich correspond to every digit=1 in s1 so i could > obtain the word "love", this is like the trivial ciphers we know in > our childhood, i have the following approach, i hope there is other > versions. > > p = Flatten[Position[s1, 1]] > out[]= {1, 3, 6, 8} > > str = ""; > Do[str = StringJoin[str, ToString[s2[[p[[i]]]]]], {i, 1, 4}] > str > > Out[]= Love > > thanks > zak > >