- Коректно
- 8 успешни тест(а)
- 0 неуспешни тест(а)
........ ---------------------------------------------------------------------- Ran 8 tests in 0.154s OK
Срокът за предаване на решения е отминал
Време е за шиб*но предизвикателство!
Искаме да направим функция, която да проверява даден текст за мръсни думи (възможно е да я ползваме за бъдещи постове, така че се постарайте!).
Искаме функцията find_dirty_words да приема:
Освен това обаче, ще дефинираме някои правила за мръснотата на думите:
Като резултат искаме да получим речник, оформен по следния начин:
{
'dirty_words': [...], # намерените мръсни думи
'censored_dirty_words': [...] # цензурираните мръсни думи
'allowed_dirty_words': [...] # мръсните думи, които отговарят на правилата за използване на мръсни думи
}
>>> print(find_dirty_words("I don't know whether to worship at your feet or (spank) the living sh*t out of you.",
["shit", "spank", "you", "feet"])) # Christian Grey
{'dirty_words': ['feet'], 'censored_dirty_words': ['sh*t'], 'allowed_dirty_words': ['spank', 'you']}
>>> print(find_dirty_words("""Искам с теб да бъде много тайно...
И да свършиш в мене уж случайно...
Да ме [ближеш] сякаш съм от захар...
Блъскай силно хайде – MOTHER **CKER...""",
["свършиш", "ближеш", "захар", "Блъскам", "DUCKER"])) # Азис
{'dirty_words': ['свършиш'], 'censored_dirty_words': ['**CKER'], 'allowed_dirty_words': ['ближеш', 'захар']}
Въпреки всичките простотии, държим да отбележим, че не сме селяни в лошата употреба на думата и цинизмът ни си има граници. Не бихме говорили по крайно вулгарният начин, описан в предизвикателството, извън форсмажорни обстоятелства, свързани с трафика. Всичко по-горе е единствено за целта на предизвикателството, мамка му. Може би освен това в последната бележка, който си го има - си го има.
Не се притеснявайте от кофти syntax highliting-a, който е много възможно да видите на сайта, след предаване на решенията си.
Сайтът се държи странно с нестандартни поредици от символи (id est регулярни изрази), но ако кодът ви върви като го тествате ръчно, няма да има проблем и при нашите тестове.
........ ---------------------------------------------------------------------- Ran 8 tests in 0.154s OK
.FFF.F..
======================================================================
FAIL: test_censored_only (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AssertionError: Element counts were not equal:
First has 0, Second has 1: 's****ed'
======================================================================
FAIL: test_censored_within_brackets_or_punctuation (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AssertionError: Element counts were not equal:
First has 0, Second has 1: 'mou**'
First has 0, Second has 1: '**arving'
First has 0, Second has 1: 'p*owl'
======================================================================
FAIL: test_dirty_before_non_terminating_punctuation (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AssertionError: Element counts were not equal:
First has 1, Second has 4: 'me'
First has 0, Second has 1: 'thirsty'
First has 0, Second has 1: 'cankered'
======================================================================
FAIL: test_dirty_in_other_words (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AssertionError: Element counts were not equal:
First has 2, Second has 0: 'as'
----------------------------------------------------------------------
Ran 8 tests in 0.190s
FAILED (failures=4)
EEEEEEEE
======================================================================
ERROR: test_allowed_only (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
KeyError: 'censored_dity_words'
======================================================================
ERROR: test_censored_only (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
KeyError: 'censored_dity_words'
======================================================================
ERROR: test_censored_within_brackets_or_punctuation (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
KeyError: 'censored_dity_words'
======================================================================
ERROR: test_dirty_before_non_terminating_punctuation (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
KeyError: 'censored_dity_words'
======================================================================
ERROR: test_dirty_everything (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
KeyError: 'censored_dity_words'
======================================================================
ERROR: test_dirty_in_other_words (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
KeyError: 'censored_dity_words'
======================================================================
ERROR: test_dirty_only (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
KeyError: 'censored_dity_words'
======================================================================
ERROR: test_dirty_with_curly_brackets (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
KeyError: 'censored_dity_words'
----------------------------------------------------------------------
Ran 8 tests in 0.134s
FAILED (errors=8)
...F.F.F
======================================================================
FAIL: test_dirty_before_non_terminating_punctuation (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AssertionError: Element counts were not equal:
First has 1, Second has 4: 'me'
First has 0, Second has 1: 'thirsty'
First has 0, Second has 1: 'cankered'
======================================================================
FAIL: test_dirty_in_other_words (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AssertionError: Element counts were not equal:
First has 1, Second has 0: 'men'
======================================================================
FAIL: test_dirty_with_curly_brackets (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AssertionError: Element counts were not equal:
First has 0, Second has 1: 'splayed'
First has 0, Second has 1: 'feast'
----------------------------------------------------------------------
Ran 8 tests in 0.136s
FAILED (failures=3)
.F.F....
======================================================================
FAIL: test_censored_only (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AssertionError: Element counts were not equal:
First has 1, Second has 0: '****'
======================================================================
FAIL: test_dirty_before_non_terminating_punctuation (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AssertionError: Element counts were not equal:
First has 1, Second has 4: 'me'
First has 0, Second has 1: 'thirsty'
First has 0, Second has 1: 'cankered'
----------------------------------------------------------------------
Ran 8 tests in 0.188s
FAILED (failures=2)
........ ---------------------------------------------------------------------- Ran 8 tests in 0.296s OK
.F.FF...
======================================================================
FAIL: test_censored_only (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AssertionError: Element counts were not equal:
First has 0, Second has 1: 'c*m*s'
======================================================================
FAIL: test_dirty_before_non_terminating_punctuation (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AssertionError: Element counts were not equal:
First has 3, Second has 4: 'me'
======================================================================
FAIL: test_dirty_everything (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AssertionError: Element counts were not equal:
First has 0, Second has 1: 'ц*цата'
----------------------------------------------------------------------
Ran 8 tests in 0.142s
FAILED (failures=3)
.FFF.F..
======================================================================
FAIL: test_censored_only (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AssertionError: Element counts were not equal:
First has 0, Second has 1: 's****ed'
======================================================================
FAIL: test_censored_within_brackets_or_punctuation (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AssertionError: Element counts were not equal:
First has 0, Second has 1: 'mou**'
======================================================================
FAIL: test_dirty_before_non_terminating_punctuation (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AssertionError: Element counts were not equal:
First has 5, Second has 4: 'me'
======================================================================
FAIL: test_dirty_in_other_words (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AssertionError: Element counts were not equal:
First has 1, Second has 0: 'ass'
First has 2, Second has 0: 'side'
First has 1, Second has 0: 'men'
First has 1, Second has 0: 'not'
----------------------------------------------------------------------
Ran 8 tests in 0.146s
FAILED (failures=4)
F...F..F
======================================================================
FAIL: test_allowed_only (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AssertionError: Element counts were not equal:
First has 1, Second has 0: 'teats'
======================================================================
FAIL: test_dirty_everything (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AssertionError: Element counts were not equal:
First has 0, Second has 1: 'ц*цата'
======================================================================
FAIL: test_dirty_with_curly_brackets (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AssertionError: Element counts were not equal:
First has 0, Second has 1: 'feast'
----------------------------------------------------------------------
Ran 8 tests in 0.114s
FAILED (failures=3)
.F.F.F..
======================================================================
FAIL: test_censored_only (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AssertionError: Element counts were not equal:
First has 1, Second has 0: '****'
======================================================================
FAIL: test_dirty_before_non_terminating_punctuation (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AssertionError: Element counts were not equal:
First has 3, Second has 4: 'me'
======================================================================
FAIL: test_dirty_in_other_words (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AssertionError: Element counts were not equal:
First has 1, Second has 0: 'ass'
First has 2, Second has 0: 'side'
First has 1, Second has 0: 'not'
----------------------------------------------------------------------
Ran 8 tests in 0.281s
FAILED (failures=3)
.FFF...F
======================================================================
FAIL: test_censored_only (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AssertionError: Element counts were not equal:
First has 0, Second has 1: 's****ed'
======================================================================
FAIL: test_censored_within_brackets_or_punctuation (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AssertionError: Element counts were not equal:
First has 0, Second has 1: 'mou**'
First has 0, Second has 1: '**arving'
======================================================================
FAIL: test_dirty_before_non_terminating_punctuation (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AssertionError: Element counts were not equal:
First has 1, Second has 4: 'me'
First has 0, Second has 1: 'thirsty'
First has 0, Second has 1: 'cankered'
======================================================================
FAIL: test_dirty_with_curly_brackets (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AssertionError: Element counts were not equal:
First has 0, Second has 1: 'feast'
----------------------------------------------------------------------
Ran 8 tests in 0.227s
FAILED (failures=4)
.FFFFF.F
======================================================================
FAIL: test_censored_only (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AssertionError: Element counts were not equal:
First has 0, Second has 1: 's****ed'
First has 0, Second has 1: '***dal'
First has 0, Second has 1: 'c*m*s'
First has 0, Second has 1: 'in**'
======================================================================
FAIL: test_censored_within_brackets_or_punctuation (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AssertionError: Element counts were not equal:
First has 1, Second has 0: 'h*ir.'
First has 0, Second has 1: 'mou**'
First has 0, Second has 1: 'h*ir'
First has 0, Second has 1: '**arving'
First has 0, Second has 1: 'p*owl'
======================================================================
FAIL: test_dirty_before_non_terminating_punctuation (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AssertionError: Element counts were not equal:
First has 1, Second has 4: 'me'
First has 0, Second has 1: 'thirsty'
First has 0, Second has 1: 'cankered'
======================================================================
FAIL: test_dirty_everything (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AssertionError: Element counts were not equal:
First has 0, Second has 1: 'ц*цата'
======================================================================
FAIL: test_dirty_in_other_words (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AssertionError: Element counts were not equal:
First has 2, Second has 0: 'side'
======================================================================
FAIL: test_dirty_with_curly_brackets (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AssertionError: Element counts were not equal:
First has 0, Second has 1: 'splayed'
First has 0, Second has 1: 'feast'
----------------------------------------------------------------------
Ran 8 tests in 0.208s
FAILED (failures=6)
..FF...F
======================================================================
FAIL: test_censored_within_brackets_or_punctuation (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AssertionError: Element counts were not equal:
First has 0, Second has 1: '**arving'
First has 0, Second has 1: 'p*owl'
======================================================================
FAIL: test_dirty_before_non_terminating_punctuation (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AssertionError: Element counts were not equal:
First has 1, Second has 4: 'me'
First has 0, Second has 1: 'thirsty'
First has 0, Second has 1: 'cankered'
======================================================================
FAIL: test_dirty_with_curly_brackets (test.TestDirtyWords)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AssertionError: Element counts were not equal:
First has 0, Second has 1: 'feast'
----------------------------------------------------------------------
Ran 8 tests in 0.172s
FAILED (failures=3)