Results 1 to 7 of 7

Thread: Who? What?

  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Cumberland, Maryland, USA
    Posts
    880
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Who? What?

    A coded message from a famous work of literature. Think "shifts" to break the code.

    "Sdaj E qoa w sknz," Dqilpu Zqilpu owez, "ej w nwpdan oyknjbqh pkja, "ep iawjo fqop sdwp E ydkkoa ep pk iawj

  2. #2
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Dallas, Texas, USA
    Posts
    1,680
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Who? What?

    These are fun...

    <blockquote><hr><center><span style="background-color: #FFFF00; color: #000000; font-weight: bold"><font color=yellow>When I use a word," Humpty Dumpty said, "in a rather scornful tone, "it means just what I choose it to mean
    - Ricky

  3. #3
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Cumberland, Maryland, USA
    Posts
    880
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Who? What?

    Bravo! You looked through the glass perfectly.

  4. #4
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Who? What?

    Last time someone posted one of these, I knocked up a quick word macro to try each possible shift in turn. Saves hours <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>

    StuartR
    <code>
    Sub DecodeIt()
    Dim i As Integer, j As Integer
    Dim chrNext As String
    Dim chrMod As String
    Dim paraNext As Paragraph
    For j = 1 To 57
    ActiveDocument.Content.InsertAfter vbCrLf
    For i = 1 To Len(ActiveDocument.Paragraphs(1).Range)
    chrNext = Mid(ActiveDocument.Paragraphs(1).Range, i, 1)
    If Asc(chrNext) <= Asc("z") And Asc(chrNext) >= Asc("A") Then
    chrMod = Chr$(Asc(chrNext) + j)
    If Asc(chrMod) > Asc("z") Then chrMod = Chr$(Asc(chrMod) - 58)
    Else
    chrMod = chrNext
    End If
    ActiveDocument.Content.InsertAfter chrMod
    Next i
    Next j

    For Each paraNext In ActiveDocument.Paragraphs
    If Len(paraNext.Range) > 2 And paraNext.Range.SpellingErrors.Count = 0 Then
    paraNext.Range.Select
    Exit Sub
    End If
    Next paraNext

    End Sub
    </code>

  5. #5
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Dallas, Texas, USA
    Posts
    1,680
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Who? What?

    And this UDF will work for Excel. With the crypted msg in cell A1 and any number between 1 and 25 (representing the shift) in cell B1.
    This formula in any other cell will help decipher the msg:

    <font color=blue>=SHIFT(A1,B1)</font color=blue>

    <pre>Function SHIFT(orgtext As String, shft As Integer) As String
    Dim i As Integer
    Dim j As Integer
    'Edited
    'Added for shft > 26
    shft = shft Mod 26
    For i = 1 To Len(orgtext)
    j = 0
    If Asc(Mid(orgtext, i, 1)) >= 65 And Asc(Mid(orgtext, i, 1)) <= 90 Then
    If Asc(Mid(orgtext, i, 1)) + shft > 90 Then j = 26
    SHIFT = SHIFT & Chr(Asc(Mid(orgtext, i, 1)) + shft - j)
    ElseIf Asc(Mid(orgtext, i, 1)) >= 97 And Asc(Mid(orgtext, i, 1)) <= 122 Then
    If Asc(Mid(orgtext, i, 1)) + shft > 122 Then j = 26
    SHIFT = SHIFT & Chr(Asc(Mid(orgtext, i, 1)) + shft - j)
    Else
    SHIFT = SHIFT & Chr(Asc(Mid(orgtext, i, 1)))
    End If
    Next i
    End Function</pre>

    BTW, Sorry about the appearance of the code. Never got the knack of where to indent...

    I haven't tried the Word code you've provided, yet. But , it looks like there's a line that will check for spelling errors. Will this code actually go through all the shifting scenarios and then stop when a "correct" solution is discovered? If so, that makes much more sense than manually reeling through the possibilities with the Excel UDF.

    The original purpose of the UDF was to make a puzzle....not solve one! I posted several of these some months ago that were created using that UDF. Seems like you promptly solved 'em using the Word code. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>
    - Ricky

  6. #6
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Who? What?

    > Will this code actually go through all the shifting scenarios and then stop when a "correct" solution is discovered?

    It tries. If it finds a paragraph with no spelling errors then it will select it. Not always successful, for example I came up with the following shifted text for this one.
    <span style="background-color: #FFFF00; color: #000000; font-weight: bold"><font color=yellow>
    "When I use A worD," Humpty ^umpty sAiD, "in A rAther sCornful tone, "it meAns just whAt I Choose it to meAn

  7. #7
    4 Star Lounger SteveH's Avatar
    Join Date
    Jan 2001
    Location
    Chelsea, Gtr London, United Kingdom
    Posts
    587
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Who? What?

    <hr>BTW, Sorry about the appearance of the code. Never got the knack of where to indent...
    <hr>

    Have you tried Smart Indenter? It's <img src=/S/free.gif border=0 alt=free width=30 height=15>
    Steve H
    IT Lecturer/Access Developer
    O2K SR3/O2010; Win7Pro

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •