Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: simple cipher

  • To: mathgroup at
  • Subject: [mg55383] Re: [mg55364] simple cipher
  • From: "David Park" <djmp at>
  • Date: Mon, 21 Mar 2005 03:01:49 -0500 (EST)
  • Sender: owner-wri-mathgroup at


When combining two objects of equal length I always think the Inner command.

s1 = {1, 0, 1, 0, 0, 1, 0, 1};
s2 = {L, r, o, w, e, v, y, e};

Inner[If[#1 == 1, ToString[#2],
      Unevaluated[Sequence[]]] &, s1, s2, StringJoin]

David Park
djmp at

From: zak [mailto:chocolatez at]
To: mathgroup at

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

p = Flatten[Position[s1, 1]]
out[]= {1, 3, 6, 8}

str = "";
Do[str = StringJoin[str, ToString[s2[[p[[i]]]]]], {i, 1, 4}]

Out[]= Love


  • Prev by Date: Re: simple cipher
  • Next by Date: Re: Do loop is faulty
  • Previous by thread: Re: simple cipher
  • Next by thread: Re: simple cipher