Ad
Algorithms
Logic
Code
Diff
  • def get_nth_words(tmpl, num):
        return ' '.join(tmpl.split()[num-1::num]) if num > 0 else ""
        
    • import re
    • def get_nth_words(tmpl, num):
    • return ' '.join(re.search(r'(\w*)[\W]?'*(tmpl.count(" ")+1), tmpl).groups()[num-1::num] if num > 0 else list())
    • return ' '.join(tmpl.split()[num-1::num]) if num > 0 else ""
Arrays
Data Types
Strings
Numbers
Code
Diff
  • def small_big_num(x):
        if type(x) != type(''): return []
        digits = [int(i) for i in x if i.isdigit()]; digits.sort()
        return [digits[-1], digits[0]]
    • def small_big_num(x):
    • try:
    • digits = [n for n in range(10) if str(n) in x]
    • return digits[::len(digits)-1][::-1]
    • except:
    • return []
    • if type(x) != type(''): return []
    • digits = [int(i) for i in x if i.isdigit()]; digits.sort()
    • return [digits[-1], digits[0]]