Re: simple cipher
- To: mathgroup at smc.vnet.net
- Subject: [mg55381] Re: [mg55364] simple cipher
- From: yehuda ben-shimol <bsyehuda at gmail.com>
- Date: Mon, 21 Mar 2005 03:01:47 -0500 (EST)
- References: <200503200911.EAA28753@smc.vnet.net>
- Reply-to: yehuda ben-shimol <bsyehuda at gmail.com>
- Sender: owner-wri-mathgroup at wolfram.com
Hi,
I assume that a funcitonal programming approach will be faster for long strings
p = StringJoin[ToString /@ Flatten[s2[[#]] & /@ Position[s1, 1]]].
And if you will already define s2 as a list of characters it will be
even simpler since you will have to implement ToString only once,
i.e.,
s3 = ToString /@ s2
p3== StringJoin[Flatten[s3[[#]] & /@ Position[s1, 1]]]
yehuda
On Sun, 20 Mar 2005 04:11:56 -0500 (EST), zak <chocolatez at gmail.com> wrote:
> 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
>
>
- References:
- simple cipher
- From: zak <chocolatez@gmail.com>
- simple cipher