a puzzle maker I wrote

Feb 6, 2010 at 3:44am
closed account (j3bk4iN6)
Sorry its in python, I have yet to make it in C++. But I made a puzzle maker like the newspapers, using ceasar cypher. I have to make the a-z circular so that it stays within a-z. and I have to add a random generator for the shift, but knowing the shift value can be used for the decoder. I was intereseted in the different cyphers, especially the one that uses a word as a shift, some french name. This program is trivial to me so I don't care if I share it, its a derivitive of an encoding program. I made it so it will print the spaces, and punctiation in the output. It might give you a look to see how easy python is to code. You should be able to see the similiarity's.



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#   A program that uses Ceaser cipher to encode a message by shifting the plain
#   text message to a fixed number

import string   #include string library for split function

def main():
    print "Function name: text2numbers()"
    print "Function name: numbers2text()"
    text2numbers()

#text2numbers
#   A program to convert a textual message into a sequence of
#   numbers, utilizing the underlying ASCII encoding.

def text2numbers():
    print "This program converts a textual message into a sequence"
    print "of numbers representing the ASCII encoding of the message."
    print

    #Get the message to encode.
    message = raw_input("Please enter the message to encode: ")
    x = input("Enter number to shift: ")

    print
    print "Here are the codes:"

    #Loop through the message and print out the ASCII values
    for ch in message:
        
        newch = ord(ch) + x  #this is where you shift
        if newch == 32 + x:
            print " ",
        elif newch == 44 + x:
            print ","
        elif newch == 39 + x:
            print "'",
        elif newch == 46 + x:
            print "."
        elif newch == 59 + x:
            print ";"
        elif newch != 32 + x:    
            print newch,  #use comma to print all on one line
        


#numbers2text
#   A program to convert a sequence of ASCII numbers into a string of text.

def numbers2text():
    print "This program converts a sequence of ASCII numbers into"
    print "the string of text that it represents."
    print

    #Get the message to encode
    inString = raw_input("Please enter the ASCII-encoded message: ")
    x = input("Enter the shift: ")

    #Loop through each substring and build ASCII message
    message = ""
    newString = []
    for numStr in string.split(inString):
        asciiNum = eval(numStr)         #convert digits to number
        newString.append(chr(asciiNum - x))
        newString1 = string.join(newString, "")
        #message = message + chr(asciiNum)       #append character to message

    #print "The decoded message is:" , message
    print newString1


main()
Feb 6, 2010 at 3:47am
http://www.cplusplus.com/
Hmm...
Last edited on Feb 6, 2010 at 3:48am
Feb 6, 2010 at 3:51am
closed account (j3bk4iN6)
sorry I don't have any c++ creations as of yet. the one I think thats really cool is converting from a number in range of 1-256 to output its 8bit binary number. converting from binary to int was easier, and I like this forum so I won't post tons of python code. Just wanted to share. I know that people can't just post other languages, because I know that some people know alot more and its confusing, but pythons really simple. And pythons a free download at python.org. Just if anyones interested. I got bored of python though, so I took up C++
Last edited on Feb 6, 2010 at 4:01am
Feb 6, 2010 at 4:11am
Then you'll love this thread: http://www.cplusplus.com/forum/general/10898/

If you want to post non-C/++, use the lounge.
Feb 6, 2010 at 4:16am
closed account (j3bk4iN6)
Oh... ok you can send this thread to the garbage collector if you need to.
Feb 6, 2010 at 11:31am
closed account (jLNv0pDG)
If nothing else, at least Python code always looks nice. Although, you should probably update it to use the new print("string") function format.

---

Why not try converting it to c++?
Topic archived. No new replies allowed.