1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

"decrypting" letters - help

Discussion in 'Programming' started by endrezr, Oct 18, 2007.

  1. #1
    HI

    I need help to write a program that tells wich letter is used instead of wich number, that is:

    donald
    +gerald
    --------
    robert
    the idea is that the program find's out what number is a, b, etc..
    possibly in visual basic language
    or at least links to some useful pages..

    thanks
     
    endrezr, Oct 18, 2007 IP
    Alexander the Great likes this.
  2. firesexwater

    firesexwater Peon

    Messages:
    19
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    use arrays (this is not a specific programming language):

    a= {a,b,c,d,e, ... ,z}
    b= {0,1,2,3,4, ... ,25}
    c= [] = {d,a,n,i,e,l} = "daniel"

    c[5] = get first character of string;


    for i = 0 to i < 26 i++
    {

    if c[0] == a
    {
    then print c[5] is equal to i++;
    }

    }


    you could put that in a greater loop if you needed to extract all characters:

    c[]
    string = "daniel"
    d = get length of string

    for i = 0 to i < d i++
    {
    c = character i from the right in string
    }

    for j = 0 to j < d j++
    {
    for i = 0 to i < 26 i++
    {

    if c[j] == a
    {
    then print c[j] is equal to i++; /n
    }
    }
    }

    that would spit out

    l is equal to 12
    e is equal to 5
    ...
    d is equal to 4
     
    firesexwater, Oct 18, 2007 IP
    Alexander the Great likes this.
  3. Forrest

    Forrest Peon

    Messages:
    500
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    0
    #3
    ... or you could just use their ASCII character numbers. I think A is 65?
     
    Forrest, Oct 18, 2007 IP
  4. firesexwater

    firesexwater Peon

    Messages:
    19
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    i don't think that is what he wanted since he is trying to add two different words to come up with a new word ... i think???

    or he could just:
    string = "Daniel"
    convert string to all lowercase

    then like you said get the ASCII number:

    g = get ASCII(c[0])
    g = g - 112

    that is if 113 is the ASCII code for lowercase L
     
    firesexwater, Oct 18, 2007 IP
  5. Forrest

    Forrest Peon

    Messages:
    500
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Right. If A is 65 and Z is 91, and I could be off on the #s, you would add the first letter of each word, then the second letters, and so forth, to get the output string. To decrypt, you subtract them.

    To make it simple, you can subtract 64 from the numeric value, so that A = 1 and B = 2 ... then if you add two letters and the answer comes to > 26, you subtract 26 and see where you land. So A = 1, but 27 also comes to A. When subtracting, if you get negative, you would add 26.

    You can use the modulo operator ( A + B + C + X % 26 ) to just get to the remainder.
     
    Forrest, Oct 18, 2007 IP
  6. endrezr

    endrezr Peon

    Messages:
    4
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    In details, I was thinking of something like this:
    in visual basic:
    for i1=1 to 9 do
    A=i1
    for i2=1 to 9 do
    B=i2
    for i3=1 to 9 do
    B=i3
    (etc. for all the letters that are important for this case)

    if (100000*D+10000*O+1000*N+100*A+10*L+D)+
    +(100000*G+10000*E+1000*R+100*A+10*L+D)=
    =(100000*RG+10000*O+1000*B+100*E+10*R+T) then
    the program displays the found values for each letter
     
    endrezr, Oct 19, 2007 IP
  7. endrezr

    endrezr Peon

    Messages:
    4
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Private Sub cmdStart_Click()
    Dim D As Double
    Dim O As Double
    Dim N As Double
    Dim A As Double
    Dim L As Double
    Dim G As Double
    Dim E As Double
    Dim R As Double
    Dim B As Double
    Dim T As Double
    'Dim i1 As Double

    'Dim i2, i3, i4, i5, i6, i7, i8, i9, i10 As Double



    For D = 1 To 9
    Next D
    For O = 1 To 9
    Next O
    For N = 1 To 9
    Next N
    For A = 1 To 9
    Next A
    For L = 1 To 9
    'L = i5
    Next L
    For G = 1 To 9
    'G = i6
    Next G
    For E = 1 To 9
    'E = i7
    Next E
    For R = 1 To 9
    'R = i8
    Next R
    For B = 1 To 9
    'B = i9
    Next B
    For T = 1 To 9
    'T = i10
    Next T
    If (100000 * D + 10000 * O + 1000 * N + 100 * A + 10 * L + D) + (100000 * G + 10000 * E + 1000 * R + 100 * A + 10 * L + D) = (100000 * R + 10000 * O + 1000 * B + 100 * E + 10 * R + T) Then
    'MsgBox (D & "is D")
    txtD.Text = D
    End If

    'MsgBox ("A=" & i1)

    End Sub

    I did this code, but at the end the txtD.Text stays empty, why?????
     
    endrezr, Oct 19, 2007 IP
  8. endrezr

    endrezr Peon

    Messages:
    4
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Here is the new version:

    Private Sub cmdStart_Click()
    Dim D As Double
    Dim O As Double
    Dim N As Double
    Dim A As Double
    Dim L As Double
    Dim G As Double
    Dim E As Double
    Dim R As Double
    Dim B As Double
    Dim T As Double
    'Dim i1 As Double

    'Dim i2, i3, i4, i5, i6, i7, i8, i9, i10 As Double



    For D = 1 To 9
    For O = 1 To 9
    For N = 1 To 9
    For A = 1 To 9
    For L = 1 To 9
    For G = 1 To 9
    For E = 1 To 9
    For R = 1 To 9
    For B = 1 To 9
    For T = 1 To 9
    If (100000 * D + 10000 * O + 1000 * N + 100 * A + 10 * L + D) + (100000 * G + 10000 * E + 1000 * R + 100 * A + 10 * L + D) = (100000 * R + 10000 * O + 1000 * B + 100 * E + 10 * R + T) Then
    'MsgBox (D & "is D")
    txtD.Text = D
    End If
    Next T
    Next B
    Next R
    Next E
    Next G
    Next L
    Next A
    Next N
    Next O
    Next D



    MsgBox ("A=" & A) 'for example to diplay the num value of A

    End Sub
     
    endrezr, Oct 19, 2007 IP