Advertisement
fkudinov

6. Common Words / Вирішуємо задачі на Python CheckIO Українською

Sep 1st, 2023
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | Source Code | 0 0
  1. # -------------      tasks/common_words.py   ---------------
  2.  
  3. def checkio(first, second):
  4.     first = set(first.split(","))
  5.     second = set(second.split(","))
  6.  
  7.     res = first.intersection(second)
  8.     return ",".join(sorted(res))
  9.  
  10. # -----------           tests/test_common_words.py    -----------------
  11.  
  12. import pytest
  13. from tasks.common_words import checkio
  14.  
  15.  
  16. @pytest.mark.parametrize(["item1", "item2", "res"], [
  17.     ["hello,world", "hello,earth", "hello"],
  18.     ["hello,world,hello", "hello,earth,hello", "hello"],
  19.     ["one,two,three", "four,five,six", ""],
  20.     ["one,two,three", "four,five,one,two,six,three", "one,three,two"],
  21. ])
  22. def test_common_words(item1, item2, res):
  23.     assert checkio(item1, item2) == res
  24.  
Tags: checkio
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement