from utils.checks import check def mix(values): """ Returns elements that are: - either in `a` OR `b` but NOT in both. AND - are common with elements in `c` """ a, b, c = values # Put your code here. data = ( (['ab', 'bc', 'ad'], {'a'}), ([[1, 2], [2, 3, 4], [3, 4]], {3, 4}), ([[1, 'a'], ['b', 3], [3, 4]], {3}), ) check(mix, data)
from utils.checks import check valid_letters = 'bcdefghijklmnopqrstuvwxyz' def unique_letters(word): """ Returns string of sorted unique letters that are both in `word` and `valid_letters`. Case insensitive! """ return ''.join(sorted(set(word.lower()) & set(valid_letters))) data = (('Bike', 'beik'), ('Molllly', 'lmoy'), ('Abrakadabra', 'abdkr'), ('Ala ma kota', 'aklmot')) check(unique_letters, data)
from utils.checks import check valid_letters = 'bcdefghijklmnopqrstuvwxyz' def unique_letters(word): """ Returns string of sorted unique letters that are both in `word` and `valid_letters`. Case insensitive! """ return ''.join(sorted(set(word.lower()) & set(valid_letters))) data = ( ('Bike', 'beik'), ('Molllly', 'lmoy'), ('Abrakadabra', 'abdkr'), ('Ala ma kota', 'aklmot') ) check(unique_letters, data)
'kota' ) def is_valid(value): """ Returns True if `value` is in either of: - valid_letters (case insensitive) - valid_numbers - valid_words (case insensitive) or False otherwise. """ # Put your code here. data = ( ('a', True), ('b', True), ('D', False), ('1', False), (1, True), ('Ala', True), ('ala', False), ('Ma', False), ('130', False), ) check(is_valid, data)
valid_letters = 'AaBbCcIiZz' valid_numbers = (1, 2, 3, 4, 100, 101, 102, 103, 104) valid_words = ('Ala', 'ma', 'kota') def is_valid(value): """ Returns True if `value` is in either of: - valid_letters (case insensitive) - valid_numbers - valid_words (case insensitive) or False otherwise. """ # Put your code here. data = ( ('a', True), ('b', True), ('D', False), ('1', False), (1, True), ('Ala', True), ('ala', False), ('Ma', False), ('130', False), ) check(is_valid, data)