






import pytest

from datasets.splits import SplitDict, SplitInfo
from datasets.utils.py_utils import asdict

@pytest.mark.parametrize(
    'split_dict'      ,       [
        SplitDict(),
        SplitDict({'train': SplitInfo(name='train'      ,       num_bytes=1_3_3_7      ,       num_examples=4_2      ,       dataset_name='my_dataset'    )}    ),
        SplitDict({'train': SplitInfo(name='train'      ,       num_bytes=1_3_3_7      ,       num_examples=4_2    )}    ),
        SplitDict({'train': SplitInfo()}    ),
    ]      ,       )
def     snake_case   (UpperCAmelCase__    )			->							List[Any]:
  UpperCamelCase_:   int        =							split_dict._to_yaml_list()
  assert len(UpperCAmelCase__    ) == len(UpperCAmelCase__    )
  UpperCamelCase_:   Tuple        =							SplitDict._from_yaml_list(UpperCAmelCase__    )
  for split_name, split_info in split_dict.items():
    # dataset_name field is deprecated, and is therefore not part of the YAML dump
    UpperCamelCase_:   Tuple        =							None
    # the split name of split_dict takes over the name of the split info object
    UpperCamelCase_:   str        =							split_name
  assert split_dict == reloaded

@pytest.mark.parametrize(
    'split_info'      ,       [SplitInfo(), SplitInfo(dataset_name=UpperCAmelCase__    ), SplitInfo(dataset_name='my_dataset'    )]    )
def     snake_case   (UpperCAmelCase__    )			->							Dict:
  # For backward compatibility, we need asdict(split_dict) to return split info dictrionaries with the "dataset_name"
  # field even if it's deprecated. This way old versionso of `datasets` can still reload dataset_infos.json files
  UpperCamelCase_:   Dict        =							asdict(SplitDict({'train': split_info}    )    )
  assert "dataset_name" in split_dict_asdict["train"]
  assert split_dict_asdict["train"]["dataset_name"] == split_info.dataset_name

"""simple docstring"""



def 					lowerCamelCase   (     _snake_case    ,_snake_case ):
    UpperCAmelCase__	:      Optional[int]     							=					''
    for i in table:
        res += inp[i - 1]
    return res
def 					lowerCamelCase   (     _snake_case ):
    return data[1:] + data[0]
def 					lowerCamelCase   (     _snake_case    ,_snake_case ):
    UpperCAmelCase__	:      str     							=					''
    for i in range(len(_snake_case ) ):
        if a[i] == b[i]:
            res += "0"
        else:
            res += "1"
    return res
def 					lowerCamelCase   (     _snake_case    ,_snake_case ):
    UpperCAmelCase__	:      str     							=					int('0b' + data[0] + data[-1]    ,2 )
    UpperCAmelCase__	:      Optional[Any]     							=					int('0b' + data[1:3]    ,2 )
    return bin(s[row][col] )[2:]
def 					lowerCamelCase   (     _snake_case    ,_snake_case    ,_snake_case    ,_snake_case    ,_snake_case ):
    UpperCAmelCase__	:      Any     							=					message[:4]
    UpperCAmelCase__	:      Optional[Any]     							=					message[4:]
    UpperCAmelCase__	:      Dict     							=					apply_table(_snake_case    ,_snake_case )
    UpperCAmelCase__	:      Optional[Any]     							=					xor(_snake_case    ,_snake_case )
    UpperCAmelCase__	:      Dict     							=					apply_sbox(_snake_case    ,temp[:4] )  # noqa: E741
    UpperCAmelCase__	:      Tuple     							=					apply_sbox(_snake_case    ,temp[4:] )
    UpperCAmelCase__	:      List[str]     							=					'0' * (2 - len(_snake_case )) + l  # noqa: E741
    UpperCAmelCase__	:      Optional[Any]     							=					'0' * (2 - len(_snake_case )) + r
    UpperCAmelCase__	:      Optional[int]     							=					apply_table(l + r    ,_snake_case )
    UpperCAmelCase__	:      Any     							=					xor(_snake_case    ,_snake_case )
    return temp + right


if __name__ == "__main__":
    UpperCamelCase__          =	input('Enter 10 bit key: ')
    UpperCamelCase__          =	input('Enter 8 bit message: ')

    UpperCamelCase__          =	[6, 3, 7, 4, 8, 5, 10, 9]
    UpperCamelCase__          =	[3, 5, 2, 7, 4, 10, 1, 9, 8, 6]
    UpperCamelCase__          =	[2, 4, 3, 1]
    UpperCamelCase__          =	[2, 6, 3, 1, 4, 8, 5, 7]
    UpperCamelCase__          =	[4, 1, 3, 5, 7, 2, 8, 6]
    UpperCamelCase__          =	[4, 1, 2, 3, 2, 3, 4, 1]
    UpperCamelCase__          =	[[1, 0, 3, 2], [3, 2, 1, 0], [0, 2, 1, 3], [3, 1, 3, 2]]
    UpperCamelCase__          =	[[0, 1, 2, 3], [2, 0, 1, 3], [3, 0, 1, 0], [2, 1, 0, 3]]

    # key generation
    UpperCamelCase__          =	apply_table(key, paa_table)
    UpperCamelCase__          =	temp[:5]
    UpperCamelCase__          =	temp[5:]
    UpperCamelCase__          =	left_shift(left)
    UpperCamelCase__          =	left_shift(right)
    UpperCamelCase__          =	apply_table(left + right, pa_table)
    UpperCamelCase__          =	left_shift(left)
    UpperCamelCase__          =	left_shift(right)
    UpperCamelCase__          =	left_shift(left)
    UpperCamelCase__          =	left_shift(right)
    UpperCamelCase__          =	apply_table(left + right, pa_table)

    # encryption
    UpperCamelCase__          =	apply_table(message, IP)
    UpperCamelCase__          =	function(expansion, sa, sa, keya, temp)
    UpperCamelCase__          =	temp[4:] + temp[:4]
    UpperCamelCase__          =	function(expansion, sa, sa, keya, temp)
    UpperCamelCase__          =	apply_table(temp, IP_inv)
    print('Cipher text is:', CT)

    # decryption
    UpperCamelCase__          =	apply_table(CT, IP)
    UpperCamelCase__          =	function(expansion, sa, sa, keya, temp)
    UpperCamelCase__          =	temp[4:] + temp[:4]
    UpperCamelCase__          =	function(expansion, sa, sa, keya, temp)
    UpperCamelCase__          =	apply_table(temp, IP_inv)
    print('Plain text after decypting is:', PT)

