From 17aeb0995c519004471a54e88841b96844e53d54 Mon Sep 17 00:00:00 2001 From: Paul Pham Date: Mon, 22 Jun 2015 18:46:34 -0700 Subject: [PATCH 1/7] Add files for Caesar cipher example. --- examples/session03/cipher.py | 35 ++++++++++++++++++++++++++++++++++ examples/session03/decipher.py | 22 +++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 examples/session03/cipher.py create mode 100644 examples/session03/decipher.py diff --git a/examples/session03/cipher.py b/examples/session03/cipher.py new file mode 100644 index 0000000..cdfa4e1 --- /dev/null +++ b/examples/session03/cipher.py @@ -0,0 +1,35 @@ +import random + +alphabet = "abcdefghijklmnopqrstuvwxyz " + +cipher_list = list(alphabet) + +# This should be a list in order +print(cipher_list) + +message_text = "what has dates and sundays but cannot be eaten" + +random.shuffle(cipher_list) + +# This should be random now +print(cipher_list) + +cipher_text = "" + +for x in message_text: + index = alphabet_list.index(x) + cipher_char = cipher_list[index] + cipher_text += cipher_char + +# This is what +print(cipher_text) + +#new_cipher_text = "eqzergqtgvtqeqgvlqrfwaqa hgecvlvrqpeigtq fz" +decrypt_text = "" + +for y in new_cipher_text: + index = cipher_list.index(y) + decrypt_char = alphabet_list[index] + decrypt_text += decrypt_char + +print decrypt_text diff --git a/examples/session03/decipher.py b/examples/session03/decipher.py new file mode 100644 index 0000000..8a37c59 --- /dev/null +++ b/examples/session03/decipher.py @@ -0,0 +1,22 @@ +# This is the file for the deciphering partner. + +alphabet = "abcdefghijklmnopqrstuvwxyz " + +alphabet_list = list(alphabet) + +# Copy and paste the cipher list from your partner below, +# instead of the empty list. +cipher_list = [] + +# copy and paste the cipher_text from your partner in slack +# and assign it to the variable new_cipher_text +new_cipher_text = "" + +decrypt_text = "" + +for y in new_cipher_text: + index = cipher_list.index(y) + decrypt_char = alphabet_list[index] + decrypt_text += decrypt_char + +print(decrypt_text) From e1e8c6b96a8d9dcc6d3e1c26ee6b7022254ca52d Mon Sep 17 00:00:00 2001 From: Paul Pham Date: Mon, 22 Jun 2015 18:50:43 -0700 Subject: [PATCH 2/7] Add example cipher and riddle. Add alphabet_list for comparison. --- examples/session03/cipher.py | 15 ++++----------- examples/session03/decipher.py | 5 +++-- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/examples/session03/cipher.py b/examples/session03/cipher.py index cdfa4e1..4d1c15d 100644 --- a/examples/session03/cipher.py +++ b/examples/session03/cipher.py @@ -2,7 +2,10 @@ alphabet = "abcdefghijklmnopqrstuvwxyz " -cipher_list = list(alphabet) +alphabet_list = list(alphabet) + +# Create a new copy of alphabet list +cipher_list = list(alphabet_list) # This should be a list in order print(cipher_list) @@ -23,13 +26,3 @@ # This is what print(cipher_text) - -#new_cipher_text = "eqzergqtgvtqeqgvlqrfwaqa hgecvlvrqpeigtq fz" -decrypt_text = "" - -for y in new_cipher_text: - index = cipher_list.index(y) - decrypt_char = alphabet_list[index] - decrypt_text += decrypt_char - -print decrypt_text diff --git a/examples/session03/decipher.py b/examples/session03/decipher.py index 8a37c59..df6bd41 100644 --- a/examples/session03/decipher.py +++ b/examples/session03/decipher.py @@ -6,11 +6,12 @@ # Copy and paste the cipher list from your partner below, # instead of the empty list. -cipher_list = [] +cipher_list = ['v', 'w', 'u', 'q', 'k', 'm', 'g', 'z', 'l', 'n', 'e', ' ', 'd', 'b', 'x', 'y', 'i', 't', 'f', 'h', 'r', 'c', 'j', 'a', 'p', 's', 'o'] + # copy and paste the cipher_text from your partner in slack # and assign it to the variable new_cipher_text -new_cipher_text = "" +new_cipher_text = "jzvhozvfoqvhkfovbqofrbqvpfowrhouvbbxhowkokvhkb" decrypt_text = "" From 1e68bbd9471bcb0af42f82601918aa0863413114 Mon Sep 17 00:00:00 2001 From: henrykh Date: Fri, 26 Jun 2015 14:29:39 -0700 Subject: [PATCH 3/7] testing --- test.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 test.txt diff --git a/test.txt b/test.txt new file mode 100644 index 0000000..e69de29 From 15958017e168f602e837fab75eb6f9f19aecd935 Mon Sep 17 00:00:00 2001 From: henrykh Date: Fri, 26 Jun 2015 14:54:06 -0700 Subject: [PATCH 4/7] testing2 --- test.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/test.txt b/test.txt index e69de29..9daeafb 100644 --- a/test.txt +++ b/test.txt @@ -0,0 +1 @@ +test From 17b4015eeeb9133358d22b7689b2b396002968cc Mon Sep 17 00:00:00 2001 From: henrykh Date: Fri, 26 Jun 2015 15:28:45 -0700 Subject: [PATCH 5/7] more tests --- test.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/test.txt b/test.txt index 9daeafb..39bd688 100644 --- a/test.txt +++ b/test.txt @@ -1 +1,2 @@ test +test2 \ No newline at end of file From 8d989b6f440579bf21c345d8b050fa36ebf4a323 Mon Sep 17 00:00:00 2001 From: henrykh Date: Fri, 26 Jun 2015 15:35:14 -0700 Subject: [PATCH 6/7] test3 --- test.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test.txt b/test.txt index 39bd688..3ceaab5 100644 --- a/test.txt +++ b/test.txt @@ -1,2 +1,3 @@ test -test2 \ No newline at end of file +test2 +test3 \ No newline at end of file From baac96e5ef8777a5a05c0c4dc4b3b5d8ef3dd518 Mon Sep 17 00:00:00 2001 From: henrykh Date: Fri, 26 Jun 2015 15:49:10 -0700 Subject: [PATCH 7/7] test4 --- test.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test.txt b/test.txt index 3ceaab5..5c1d742 100644 --- a/test.txt +++ b/test.txt @@ -1,3 +1,4 @@ test test2 -test3 \ No newline at end of file +test3 +test4