kyu_3.rail_fence_cipher_encoding_and_decoding package

Submodules

kyu_3.rail_fence_cipher_encoding_and_decoding.encoding_and_decoding module

Solution for -> Rail Fence Cipher: Encoding and Decoding.

Created by Egor Kostan. GitHub: https://github.com/ikostan

kyu_3.rail_fence_cipher_encoding_and_decoding.encoding_and_decoding.decode_rail_fence_cipher(string: str, n: int) str[source]

Decode rail fence cipher.

Function/method that takes 2 arguments, an encoded string and the number of rails, and returns the DECODED string. :param string: str, an encoded string :param n: int, the number of rails :return: str, the DECODED string

kyu_3.rail_fence_cipher_encoding_and_decoding.encoding_and_decoding.encode_rail_fence_cipher(string: str, n: int) str[source]

Encode rail fence cipher.

This cipher is used to encode a string by placing each character successively in a diagonal along a set of “rails”. First start off moving diagonally and down. When you reach the bottom, reverse direction and move diagonally and up until you reach the top rail. Continue until you reach the end of the string. Each “rail” is then read left to right to derive the encoded string. :param string: str :param n: int, the number of rails :return: str, the ENCODED string

kyu_3.rail_fence_cipher_encoding_and_decoding.encoding_and_decoding.get_rails(string: str, n: int) list[source]

Create rails matrix.

Parameters:
  • string – str

  • n – int, the number of rails

Returns:

list, rails matrix

kyu_3.rail_fence_cipher_encoding_and_decoding.test_decoding module

Testing Decoding functionality.

Created by Egor Kostan. GitHub: https://github.com/ikostan

class kyu_3.rail_fence_cipher_encoding_and_decoding.test_decoding.DecodingTestCase(methodName='runTest')[source]

Bases: TestCase

Testing Decoding functionality.

_classSetupFailed = False
_class_cleanups = []
test_decoding = None
test_decoding_0_H_e_Wdloollr(**kw)

Testing Decoding functionality [with string=’H !e,Wdloollr’, n=4, expected=’Hello, World!’].

test_decoding_1_WECRLTEERDSOEEFEAOCAIVDEN(**kw)

Testing Decoding functionality [with string=’WECRLTEERDSOEEFEAOCAIVDEN’, n=3, expected=’WEAREDISCOVEREDFLEEATONCE’].

test_decoding_2_(**kw)

Testing Decoding functionality [with string=’’, n=3, expected=’’].

test_decoding_3_WEAREDISCOVEREDFLEEATONCE(**kw)

Testing Decoding functionality [with string=’WEAREDISCOVEREDFLEEATONCE’, n=10, expected=’WADCEDETNECOEFROIREESVELA’].

test_decoding_4_WEAREDISCOVEREDFLEEATONCE(**kw)

Testing Decoding functionality [with string=’WEAREDISCOVEREDFLEEATONCE’, n=9, expected=’WADCEDETCOEFROIREESVELANE’].

test_decoding_5_Hello_World_(**kw)

Testing Decoding functionality [with string=’Hello, World!’, n=13, expected=’Hello, World!’].

kyu_3.rail_fence_cipher_encoding_and_decoding.test_encoding module

Testing Encoding functionality.

Created by Egor Kostan. GitHub: https://github.com/ikostan

class kyu_3.rail_fence_cipher_encoding_and_decoding.test_encoding.EncodingTestCase(methodName='runTest')[source]

Bases: TestCase

Testing Encoding functionality.

_classSetupFailed = False
_class_cleanups = []
test_encoding = None
test_encoding_0_WEAREDISCOVEREDFLEEATONCE(**kw)

Testing Encoding functionality [with string=’WEAREDISCOVEREDFLEEATONCE’, n=25, expected=’WEAREDISCOVEREDFLEEATONCE’].

test_encoding_1_WEAREDISCOVEREDFLEEATONCE(**kw)

Testing Encoding functionality [with string=’WEAREDISCOVEREDFLEEATONCE’, n=3, expected=’WECRLTEERDSOEEFEAOCAIVDEN’].

test_encoding_2_Hello_World_(**kw)

Testing Encoding functionality [with string=’Hello, World!’, n=3, expected=’Hoo!el,Wrdl l’].

test_encoding_3_Hello_World_(**kw)

Testing Encoding functionality [with string=’Hello, World!’, n=4, expected=’H !e,Wdloollr’].

test_encoding_4_(**kw)

Testing Encoding functionality [with string=’’, n=3, expected=’’].

test_encoding_5_WEAREDISCOVEREDFLEEATONCE(**kw)

Testing Encoding functionality [with string=’WEAREDISCOVEREDFLEEATONCE’, n=4, expected=’WIREEEDSEEEACAECVDLTNROFO’].

test_encoding_6_WEAREDISCOVEREDFLEEATONCE(**kw)

Testing Encoding functionality [with string=’WEAREDISCOVEREDFLEEATONCE’, n=6, expected=’WVTEOEAOACRENRSEECEIDLEDF’].

test_encoding_7_WEAREDISCOVEREDFLEEATONCE(**kw)

Testing Encoding functionality [with string=’WEAREDISCOVEREDFLEEATONCE’, n=10, expected=’WEEEAALTRFOEDNDECIRESECVO’].

test_encoding_8_WEAREDISCOVEREDFLEEATONCE(**kw)

Testing Encoding functionality [with string=’WEAREDISCOVEREDFLEEATONCE’, n=5, expected=’WCLEESOFECAIVDENRDEEAOERT’].

Module contents

Codewars kyu_3 package: Rail Fence Cipher - Encoding and Decoding.