Making a Code Busters test using Python

Shoot the breeze with other Olympians.
Post Reply
Birdmusic
Member
Member
Posts: 96
Joined: October 22nd, 2017, 9:33 am
Division: C
State: CA
Pronouns: She/Her/Hers
Has thanked: 4 times
Been thanked: 18 times

Making a Code Busters test using Python

Post by Birdmusic »

So, I've been bored this summer and I made a Codebusters test with Python. (Contains monoalphabetic, affine, caesar shift, vingere, bacon, and rsa).

Would anyone be interested in checking my coding (I'm not exactly good at it, and while it runs ok, I think it can definetly be improved) or just telling me how I can make it better?

Thanks!
(If this is the wrong type of stuff to put in general, sorry!)

Edit: I just found out you can link to your respositories on github (i have no idea what i'm doing as you can tell) and it's here: https://github.com/erasedbird/Code-Busters.git
Last edited by Birdmusic on August 21st, 2018, 7:16 pm, edited 1 time in total.
I like birds.
UTF-8 U+6211 U+662F
Exalted Member
Exalted Member
Posts: 1597
Joined: January 18th, 2015, 7:42 am
Division: C
State: PA
Has thanked: 6 times
Been thanked: 15 times

Re: Making a Code Busters test using Python

Post by UTF-8 U+6211 U+662F »

Birdmusic wrote:So, I've been bored this summer and I made a Codebusters test with Python. (Contains monoalphabetic, affine, caesar shift, vingere, bacon, and rsa).

Would anyone be interested in checking my coding (I'm not exactly good at it, and while it runs ok, I think it can definetly be improved) or just telling me how I can make it better?

Thanks!
(If this is the wrong type of stuff to put in general, sorry!)
Where's your code? :P
Birdmusic
Member
Member
Posts: 96
Joined: October 22nd, 2017, 9:33 am
Division: C
State: CA
Pronouns: She/Her/Hers
Has thanked: 4 times
Been thanked: 18 times

Re: Making a Code Busters test using Python

Post by Birdmusic »

UTF-8 U+6211 U+662F wrote:
Birdmusic wrote:So, I've been bored this summer and I made a Codebusters test with Python. (Contains monoalphabetic, affine, caesar shift, vingere, bacon, and rsa).

Would anyone be interested in checking my coding (I'm not exactly good at it, and while it runs ok, I think it can definetly be improved) or just telling me how I can make it better?

Thanks!
(If this is the wrong type of stuff to put in general, sorry!)
Where's your code? :P
Sorry I forgot to put!

I have a Github called Erasedbird and the repository is Code-Busters. (I think you can search it up, but I’m kinda new to github, so if it doesn’t work, I’ll make a doc with all the code)
I like birds.
Theta
Member
Member
Posts: 1
Joined: April 14th, 2018, 6:52 am
Division: C
State: KS
Has thanked: 0
Been thanked: 0

Re: Making a Code Busters test using Python

Post by Theta »

Funny enough, I made a similar thing but in Javascript. Your code looks like it works, but could probably be simplified by writing a few functions all the ciphers can use, some things like get_num_for_letter and get_letter_for_num. Most monoalphabetic questions I've seen provide a frequency table, so you may want to add those if you want to practice it realistically using this.
Birdmusic
Member
Member
Posts: 96
Joined: October 22nd, 2017, 9:33 am
Division: C
State: CA
Pronouns: She/Her/Hers
Has thanked: 4 times
Been thanked: 18 times

Re: Making a Code Busters test using Python

Post by Birdmusic »

Theta wrote:Funny enough, I made a similar thing but in Javascript. Your code looks like it works, but could probably be simplified by writing a few functions all the ciphers can use, some things like get_num_for_letter and get_letter_for_num. Most monoalphabetic questions I've seen provide a frequency table, so you may want to add those if you want to practice it realistically using this.
Thank you! I will try to add a frequency table, and I will try to make it more efficient with the function all cipher can use.
:D

(I guess having more tests is something we all want! XD)
I like birds.
User avatar
l0lit
Member
Member
Posts: 48
Joined: July 30th, 2018, 12:20 pm
Division: C
State: FL
Has thanked: 0
Been thanked: 12 times

Re: Making a Code Busters test using Python

Post by l0lit »

Birdmusic wrote:So, I've been bored this summer and I made a Codebusters test with Python. (Contains monoalphabetic, affine, caesar shift, vingere, bacon, and rsa).

Would anyone be interested in checking my coding (I'm not exactly good at it, and while it runs ok, I think it can definetly be improved) or just telling me how I can make it better?

Thanks!
(If this is the wrong type of stuff to put in general, sorry!)

Edit: I just found out you can link to your respositories on github (i have no idea what i'm doing as you can tell) and it's here: https://github.com/erasedbird/Code-Busters.git
I did a similar thing, but not as advanced as I did not have that much time to improve it. 2 things I would add:

1. For the Baconian cipher, instead of having a giant piece of text with every Baconian letter in it, I believe that making a separate function that converts letters to numbers to binary on the spot would be more efficient. Then, for characters, you could have a list of 2-item lists. Here's an example of what I'm thinking:

Code: Select all

chars = [['A','B'],['>','<']]
alphabet = "abcdefghijklmnopqrstuvwxyz"

def letter_to_bacon(l, charlist):
    l_value = alphabet.index(l.lower())
    l_bin = "{0:b}".format(l_value)
    bacon = ""
    for char in l_bin:
        bacon += charlist[int(char)]

    # to turn into 5 letter output
    for x in range(len(bacon),5):
        bacon = "A" + bacon
    
    return bacon

# Example converting letter B using set ['A','B']
print(letter_to_bacon("b",chars[0]))
# returns "AAAAB" - correct
You can just as easily input chars[1] to change the type. This would give more versatility with binary and get competitors used to seeing Baconian that may not necessarily be "A" and "B" (like some tests I experienced last year).

2. Instead of using your plaintext.py, I think downloading the Python quotes module here. This would prevent repetition and prediction. You can even add in your own quotes!

3. My program also had a basic function to instead write the test into a .txt file, and the key into another file, for easy taking and printing. This way, the test won't disappear if you press enter, and it is best to practice on paper. If you want to make it more complex, you can write it into XML files for Word.
Any opinions stated on this site are not official, the only official information can be found at soinc.org

University of South Florida '25
Carmel SciOly Alumni, Captain 2019-21
Tests written
Birdmusic
Member
Member
Posts: 96
Joined: October 22nd, 2017, 9:33 am
Division: C
State: CA
Pronouns: She/Her/Hers
Has thanked: 4 times
Been thanked: 18 times

Re: Making a Code Busters test using Python

Post by Birdmusic »

l0lit wrote:
Birdmusic wrote:So, I've been bored this summer and I made a Codebusters test with Python. (Contains monoalphabetic, affine, caesar shift, vingere, bacon, and rsa).

Would anyone be interested in checking my coding (I'm not exactly good at it, and while it runs ok, I think it can definetly be improved) or just telling me how I can make it better?

Thanks!
(If this is the wrong type of stuff to put in general, sorry!)

Edit: I just found out you can link to your respositories on github (i have no idea what i'm doing as you can tell) and it's here: https://github.com/erasedbird/Code-Busters.git
I did a similar thing, but not as advanced as I did not have that much time to improve it. 2 things I would add:

1. For the Baconian cipher, instead of having a giant piece of text with every Baconian letter in it, I believe that making a separate function that converts letters to numbers to binary on the spot would be more efficient. Then, for characters, you could have a list of 2-item lists. Here's an example of what I'm thinking:

Code: Select all

chars = [['A','B'],['>','<']]
alphabet = "abcdefghijklmnopqrstuvwxyz"

def letter_to_bacon(l, charlist):
    l_value = alphabet.index(l.lower())
    l_bin = "{0:b}".format(l_value)
    bacon = ""
    for char in l_bin:
        bacon += charlist[int(char)]

    # to turn into 5 letter output
    for x in range(len(bacon),5):
        bacon = "A" + bacon
    
    return bacon

# Example converting letter B using set ['A','B']
print(letter_to_bacon("b",chars[0]))
# returns "AAAAB" - correct
You can just as easily input chars[1] to change the type. This would give more versatility with binary and get competitors used to seeing Baconian that may not necessarily be "A" and "B" (like some tests I experienced last year).

2. Instead of using your plaintext.py, I think downloading the Python quotes module here. This would prevent repetition and prediction. You can even add in your own quotes!

3. My program also had a basic function to instead write the test into a .txt file, and the key into another file, for easy taking and printing. This way, the test won't disappear if you press enter, and it is best to practice on paper. If you want to make it more complex, you can write it into XML files for Word.
Thank you for the great advice! I will try those out!
I like birds.
Post Reply

Return to “General Chat”

Who is online

Users browsing this forum: Ahrefs [Bot] and 1 guest