Шифърът на Цезар
- Краен срок
- 04.04.2014 23:59
Срокът за предаване на решения е отминал
Шифърът на Цезар е вид шифър с пряка субституция (субституционен шифър) - това означава, че всяка буква се замества само с една и съща друга буква, в целия текст.
Според някои исторически източници, този шифър е използван от Гай Юлий Цезар.
Предизвикателството
Напишете декоратори ceaser_output
и ceaser_input
, които да работят на базата на Шифърът на Цезар.
ceaser_output:
Променя изхода на декорираната функция със съответното отместване според Цезаровия шифър.
Декораторът приема един аргумент, който указва големината на отместването.
Пример
@ceaser_output(13)
def cross_the_river():
return "ALEA IACTA EST"
>>> print(cross_the_river())
NYRN VNPGN RFG
ceaser_input:
- също приема число за отместване
- приема и функция, която може да бъде използвана за избирателно прилагане на шифъра
Пример
@ceaser_input(-13, lambda key: key > 0)
def make_a_speech(name, *args):
print('{} says:\n{}'.format(name, ' '.join(args)))
>>> make_a_speech('Reg', 'JUNG', 'UNIR', 'GUR', 'EBZNAF',
'RIRE', 'QBAR', 'SBE', 'HF?', '...')
Reg says:
WHAT HAVE THE ROMANS EVER DONE FOR US? ...
Бележки:
- без значение са главни/малки букви за низовете, които ще бъдат шифровани, а резултатитеа от шифрирането са винаги в главни букви
- положително отместване означава преместване надясно(1: Z=>A, A=>B, B=>C ...), а отрицателно - наляво(-1: B=>A, A=>Z ...).
Решения
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Веселин Генадиев
....
----------------------------------------------------------------------
Ran 4 tests in 0.003s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Драгомир Тунчев
....
----------------------------------------------------------------------
Ran 4 tests in 0.003s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Йосиф Цветков
....
----------------------------------------------------------------------
Ran 4 tests in 0.003s
OK
-
Некоректно
- 0 успешни тест(а)
- 4 неуспешни тест(а)
Михаил Станин
F
Stdout:
Reg says:
WHAT HAVE THE ROMANS EVER DONE FOR US? ...
F
Stdout:
NYRN VNPGN RFG
F
Stdout:
XYZABCDEFGHIJKLMNOPQRSTUVW
F
Stdout:
THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG
======================================================================
FAIL: test_ceaser_input (test.TestCaesarCipher)
----------------------------------------------------------------------
Traceback (most recent call last):
File "lib/language/python/runner.py", line 60, in thread
raise it.exc_info[1]
File "lib/language/python/runner.py", line 48, in run
self.result = func(*args, **kwargs)
File "/tmp/d20140614-17226-1931jpj/test.py", line 32, in test_ceaser_input
self.assertEqual(real_input, expected_input)
AssertionError: None != 'Reg says:\nWHAT HAVE THE ROMANS EVER DONE FOR US? ...'
Stdout:
Reg says:
WHAT HAVE THE ROMANS EVER DONE FOR US? ...
======================================================================
FAIL: test_ceaser_output (test.TestCaesarCipher)
----------------------------------------------------------------------
Traceback (most recent call last):
File "lib/language/python/runner.py", line 60, in thread
raise it.exc_info[1]
File "lib/language/python/runner.py", line 48, in run
self.result = func(*args, **kwargs)
File "/tmp/d20140614-17226-1931jpj/test.py", line 13, in test_ceaser_output
self.assertEqual(decorated(), "NYRN VNPGN RFG")
AssertionError: None != 'NYRN VNPGN RFG'
Stdout:
NYRN VNPGN RFG
======================================================================
FAIL: test_output_with_overflowing (test.TestCaesarCipher)
----------------------------------------------------------------------
Traceback (most recent call last):
File "lib/language/python/runner.py", line 60, in thread
raise it.exc_info[1]
File "lib/language/python/runner.py", line 48, in run
self.result = func(*args, **kwargs)
File "/tmp/d20140614-17226-1931jpj/test.py", line 19, in test_output_with_overflowing
self.assertEqual(decorated(), "XYZABCDEFGHIJKLMNOPQRSTUVW")
AssertionError: None != 'XYZABCDEFGHIJKLMNOPQRSTUVW'
Stdout:
XYZABCDEFGHIJKLMNOPQRSTUVW
======================================================================
FAIL: test_the_quick_brown_fox (test.TestCaesarCipher)
----------------------------------------------------------------------
Traceback (most recent call last):
File "lib/language/python/runner.py", line 60, in thread
raise it.exc_info[1]
File "lib/language/python/runner.py", line 48, in run
self.result = func(*args, **kwargs)
File "/tmp/d20140614-17226-1931jpj/test.py", line 40, in test_the_quick_brown_fox
self.assertEqual(decorator(lambda: encoded)(), message)
AssertionError: None != 'THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG'
Stdout:
THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG
----------------------------------------------------------------------
Ran 4 tests in 0.004s
FAILED (failures=4)
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Божидар Михайлов
....
----------------------------------------------------------------------
Ran 4 tests in 0.002s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Тихомир Янев
....
----------------------------------------------------------------------
Ran 4 tests in 0.004s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Георги Стайков
....
----------------------------------------------------------------------
Ran 4 tests in 0.003s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Димитър Мутафчиев
....
----------------------------------------------------------------------
Ran 4 tests in 0.002s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Стефани Цакова
....
----------------------------------------------------------------------
Ran 4 tests in 0.003s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Стефан Маринов
....
----------------------------------------------------------------------
Ran 4 tests in 0.003s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Антонио Николов
....
----------------------------------------------------------------------
Ran 4 tests in 0.003s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Георги Димитров
....
----------------------------------------------------------------------
Ran 4 tests in 0.002s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Никола Димитров
....
----------------------------------------------------------------------
Ran 4 tests in 0.002s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Денис Бялев
....
----------------------------------------------------------------------
Ran 4 tests in 0.002s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Гергана Петрова
....
----------------------------------------------------------------------
Ran 4 tests in 0.002s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Стоян Ефтимов
....
----------------------------------------------------------------------
Ran 4 tests in 0.003s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Емилиан Станков
....
----------------------------------------------------------------------
Ran 4 tests in 0.002s
OK
-
Некоректно
- 3 успешни тест(а)
- 1 неуспешни тест(а)
Цветелина Борисова
F...
======================================================================
FAIL: test_ceaser_input (test.TestCaesarCipher)
----------------------------------------------------------------------
Traceback (most recent call last):
File "lib/language/python/runner.py", line 60, in thread
raise it.exc_info[1]
File "lib/language/python/runner.py", line 48, in run
self.result = func(*args, **kwargs)
File "/tmp/d20140614-17226-1yzxlhc/test.py", line 32, in test_ceaser_input
self.assertEqual(real_input, expected_input)
AssertionError: 'Reg says:\nWHAT HAVE THE ROMANS EVER DONE FOR US? ... ' != 'Reg says:\nWHAT HAVE THE ROMANS EVER DONE FOR US? ...'
Reg says:
- WHAT HAVE THE ROMANS EVER DONE FOR US? ... ? -
+ WHAT HAVE THE ROMANS EVER DONE FOR US? ...
----------------------------------------------------------------------
Ran 4 tests in 0.004s
FAILED (failures=1)
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Иван Георгиев
....
----------------------------------------------------------------------
Ran 4 tests in 0.003s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Данаил Койчев
....
----------------------------------------------------------------------
Ran 4 tests in 0.003s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Йордан Дикманов
....
----------------------------------------------------------------------
Ran 4 tests in 0.002s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Весела Бандова
....
----------------------------------------------------------------------
Ran 4 tests in 0.002s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Александър Златков
....
----------------------------------------------------------------------
Ran 4 tests in 0.003s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Ралица Цанова
....
----------------------------------------------------------------------
Ran 4 tests in 0.003s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Стефан Владков
....
----------------------------------------------------------------------
Ran 4 tests in 0.002s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Иван Бобев
....
----------------------------------------------------------------------
Ran 4 tests in 0.003s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Атанас Филчев
....
----------------------------------------------------------------------
Ran 4 tests in 0.002s
OK
-
Некоректно
- 3 успешни тест(а)
- 1 неуспешни тест(а)
Йончо Йончев
F...
======================================================================
FAIL: test_ceaser_input (test.TestCaesarCipher)
----------------------------------------------------------------------
Traceback (most recent call last):
File "lib/language/python/runner.py", line 60, in thread
raise it.exc_info[1]
File "lib/language/python/runner.py", line 48, in run
self.result = func(*args, **kwargs)
File "/tmp/d20140614-17226-19l5x49/test.py", line 32, in test_ceaser_input
self.assertEqual(real_input, expected_input)
AssertionError: 'WHAT HAVE THE ROMANS EVER DONE FOR US? ...' != 'Reg says:\nWHAT HAVE THE ROMANS EVER DONE FOR US? ...'
- WHAT HAVE THE ROMANS EVER DONE FOR US? ...
+ Reg says:
WHAT HAVE THE ROMANS EVER DONE FOR US? ...
? ++++++++++
----------------------------------------------------------------------
Ran 4 tests in 0.004s
FAILED (failures=1)
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Атанас Димитров
....
----------------------------------------------------------------------
Ran 4 tests in 0.002s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Георги Йорданов
....
----------------------------------------------------------------------
Ran 4 tests in 0.002s
OK
-
Некоректно
- 3 успешни тест(а)
- 1 неуспешни тест(а)
Мартин Георгиев
F...
======================================================================
FAIL: test_ceaser_input (test.TestCaesarCipher)
----------------------------------------------------------------------
Traceback (most recent call last):
File "lib/language/python/runner.py", line 60, in thread
raise it.exc_info[1]
File "lib/language/python/runner.py", line 48, in run
self.result = func(*args, **kwargs)
File "/tmp/d20140614-17226-1c3n23o/test.py", line 32, in test_ceaser_input
self.assertEqual(real_input, expected_input)
AssertionError: None != 'Reg says:\nWHAT HAVE THE ROMANS EVER DONE FOR US? ...'
----------------------------------------------------------------------
Ran 4 tests in 0.003s
FAILED (failures=1)
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Никола Ненков
....
----------------------------------------------------------------------
Ran 4 tests in 0.003s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Петър Парушев
....
----------------------------------------------------------------------
Ran 4 tests in 0.002s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Васил Тодоров
....
----------------------------------------------------------------------
Ran 4 tests in 0.003s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Милица Борисова
....
----------------------------------------------------------------------
Ran 4 tests in 0.002s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Елена Димитрова
....
----------------------------------------------------------------------
Ran 4 tests in 0.002s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Теодор Драганов
....
----------------------------------------------------------------------
Ran 4 tests in 0.003s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Мария Донева
....
----------------------------------------------------------------------
Ran 4 tests in 0.002s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Мария Кърчева
....
----------------------------------------------------------------------
Ran 4 tests in 0.003s
OK
-
Некоректно
- 3 успешни тест(а)
- 1 неуспешни тест(а)
Валентин Петров
E...
======================================================================
ERROR: test_ceaser_input (test.TestCaesarCipher)
----------------------------------------------------------------------
Traceback (most recent call last):
File "lib/language/python/runner.py", line 60, in thread
raise it.exc_info[1]
File "lib/language/python/runner.py", line 48, in run
self.result = func(*args, **kwargs)
File "/tmp/d20140614-17226-1r8binr/test.py", line 22, in test_ceaser_input
decorator = solution.ceaser_input(-13, lambda key: key > 0)
AttributeError: 'module' object has no attribute 'ceaser_input'
----------------------------------------------------------------------
Ran 4 tests in 0.003s
FAILED (errors=1)
-
Некоректно
- 3 успешни тест(а)
- 1 неуспешни тест(а)
Иван Латунов
E...
======================================================================
ERROR: test_ceaser_input (test.TestCaesarCipher)
----------------------------------------------------------------------
Traceback (most recent call last):
File "lib/language/python/runner.py", line 60, in thread
raise it.exc_info[1]
File "lib/language/python/runner.py", line 48, in run
self.result = func(*args, **kwargs)
File "/tmp/d20140614-17226-buvlz8/test.py", line 22, in test_ceaser_input
decorator = solution.ceaser_input(-13, lambda key: key > 0)
AttributeError: 'module' object has no attribute 'ceaser_input'
----------------------------------------------------------------------
Ran 4 tests in 0.003s
FAILED (errors=1)
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Георги Харизанов
....
----------------------------------------------------------------------
Ran 4 tests in 0.003s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Любомир Коев
....
----------------------------------------------------------------------
Ran 4 tests in 0.002s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Филип Митов
....
----------------------------------------------------------------------
Ran 4 tests in 0.002s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Евгени Евлогиев
....
----------------------------------------------------------------------
Ran 4 tests in 0.003s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Петър Камбуров
....
----------------------------------------------------------------------
Ran 4 tests in 0.002s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Емануел Стоянов
....
----------------------------------------------------------------------
Ran 4 tests in 0.003s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Николай Масларски
....
----------------------------------------------------------------------
Ran 4 tests in 0.002s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Кирил Киров
....
----------------------------------------------------------------------
Ran 4 tests in 0.003s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Теодор Халваджиев
....
----------------------------------------------------------------------
Ran 4 tests in 0.002s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Виктор Иванов
....
----------------------------------------------------------------------
Ran 4 tests in 0.002s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Дарина Кръстева
....
----------------------------------------------------------------------
Ran 4 tests in 0.002s
OK
-
Некоректно
- 3 успешни тест(а)
- 1 неуспешни тест(а)
Антония Чекръкчиева
E...
======================================================================
ERROR: test_ceaser_input (test.TestCaesarCipher)
----------------------------------------------------------------------
Traceback (most recent call last):
File "lib/language/python/runner.py", line 60, in thread
raise it.exc_info[1]
File "lib/language/python/runner.py", line 48, in run
self.result = func(*args, **kwargs)
File "/tmp/d20140614-17226-1ko4e5z/test.py", line 22, in test_ceaser_input
decorator = solution.ceaser_input(-13, lambda key: key > 0)
AttributeError: 'module' object has no attribute 'ceaser_input'
----------------------------------------------------------------------
Ran 4 tests in 0.003s
FAILED (errors=1)
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Георги Янев
....
----------------------------------------------------------------------
Ran 4 tests in 0.002s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Димитър Трендафилов
....
----------------------------------------------------------------------
Ran 4 tests in 0.002s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Стоян Христов
....
----------------------------------------------------------------------
Ran 4 tests in 0.002s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Марио Димитров
....
----------------------------------------------------------------------
Ran 4 tests in 0.002s
OK
-
Некоректно
- 0 успешни тест(а)
- 4 неуспешни тест(а)
Герасим Станчев
EEEE
======================================================================
ERROR: test_ceaser_input (test.TestCaesarCipher)
----------------------------------------------------------------------
Traceback (most recent call last):
File "lib/language/python/runner.py", line 60, in thread
raise it.exc_info[1]
File "lib/language/python/runner.py", line 48, in run
self.result = func(*args, **kwargs)
File "/tmp/d20140614-17226-1063bvt/test.py", line 22, in test_ceaser_input
decorator = solution.ceaser_input(-13, lambda key: key > 0)
AttributeError: 'module' object has no attribute 'ceaser_input'
======================================================================
ERROR: test_ceaser_output (test.TestCaesarCipher)
----------------------------------------------------------------------
Traceback (most recent call last):
File "lib/language/python/runner.py", line 60, in thread
raise it.exc_info[1]
File "lib/language/python/runner.py", line 48, in run
self.result = func(*args, **kwargs)
File "/tmp/d20140614-17226-1063bvt/test.py", line 12, in test_ceaser_output
decorated = decorator(cross_the_river)
TypeError: ceaser_transposition() takes 0 positional arguments but 1 was given
======================================================================
ERROR: test_output_with_overflowing (test.TestCaesarCipher)
----------------------------------------------------------------------
Traceback (most recent call last):
File "lib/language/python/runner.py", line 60, in thread
raise it.exc_info[1]
File "lib/language/python/runner.py", line 48, in run
self.result = func(*args, **kwargs)
File "/tmp/d20140614-17226-1063bvt/test.py", line 18, in test_output_with_overflowing
decorated = decorator(cross_the_river)
TypeError: ceaser_transposition() takes 0 positional arguments but 1 was given
======================================================================
ERROR: test_the_quick_brown_fox (test.TestCaesarCipher)
----------------------------------------------------------------------
Traceback (most recent call last):
File "lib/language/python/runner.py", line 60, in thread
raise it.exc_info[1]
File "lib/language/python/runner.py", line 48, in run
self.result = func(*args, **kwargs)
File "/tmp/d20140614-17226-1063bvt/test.py", line 40, in test_the_quick_brown_fox
self.assertEqual(decorator(lambda: encoded)(), message)
TypeError: ceaser_transposition() takes 0 positional arguments but 1 was given
----------------------------------------------------------------------
Ran 4 tests in 0.003s
FAILED (errors=4)
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Венцислав Велков
....
----------------------------------------------------------------------
Ran 4 tests in 0.003s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Деян Камбуров
....
----------------------------------------------------------------------
Ran 4 tests in 0.002s
OK
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Лъчезар Николов
....
----------------------------------------------------------------------
Ran 4 tests in 0.003s
OK
-
Некоректно
- 3 успешни тест(а)
- 1 неуспешни тест(а)
Ивайло Бъчваров
E...
======================================================================
ERROR: test_ceaser_input (test.TestCaesarCipher)
----------------------------------------------------------------------
Traceback (most recent call last):
File "lib/language/python/runner.py", line 60, in thread
raise it.exc_info[1]
File "lib/language/python/runner.py", line 48, in run
self.result = func(*args, **kwargs)
File "/tmp/d20140614-17226-qgz3q4/test.py", line 22, in test_ceaser_input
decorator = solution.ceaser_input(-13, lambda key: key > 0)
AttributeError: 'module' object has no attribute 'ceaser_input'
----------------------------------------------------------------------
Ran 4 tests in 0.003s
FAILED (errors=1)
-
Коректно
- 4 успешни тест(а)
- 0 неуспешни тест(а)
Спасимир Тупаров
....
----------------------------------------------------------------------
Ran 4 tests in 0.002s
OK
-
Некоректно
- 3 успешни тест(а)
- 1 неуспешни тест(а)
Милен Христов
E...
======================================================================
ERROR: test_ceaser_input (test.TestCaesarCipher)
----------------------------------------------------------------------
Traceback (most recent call last):
File "lib/language/python/runner.py", line 60, in thread
raise it.exc_info[1]
File "lib/language/python/runner.py", line 48, in run
self.result = func(*args, **kwargs)
File "/tmp/d20140614-17226-jja4gs/test.py", line 22, in test_ceaser_input
decorator = solution.ceaser_input(-13, lambda key: key > 0)
AttributeError: 'module' object has no attribute 'ceaser_input'
----------------------------------------------------------------------
Ran 4 tests in 0.003s
FAILED (errors=1)
-
Некоректно
- 3 успешни тест(а)
- 1 неуспешни тест(а)
Стефан Колчев
E...
======================================================================
ERROR: test_ceaser_input (test.TestCaesarCipher)
----------------------------------------------------------------------
Traceback (most recent call last):
File "lib/language/python/runner.py", line 60, in thread
raise it.exc_info[1]
File "lib/language/python/runner.py", line 48, in run
self.result = func(*args, **kwargs)
File "/tmp/d20140614-17226-111y9su/test.py", line 22, in test_ceaser_input
decorator = solution.ceaser_input(-13, lambda key: key > 0)
AttributeError: 'module' object has no attribute 'ceaser_input'
----------------------------------------------------------------------
Ran 4 tests in 0.003s
FAILED (errors=1)