Exemplo n.º 1
0
def nice(s, pat=re.compile(r'([a-z])\1')):
    """
  >>> nice('ugknbfddgicrmopn')
  True
  >>> nice('aaa')
  True
  >>> nice('jchzalrnumimnmhp')
  False
  >>> nice('haegwjzuvuyypxyu')
  False
  >>> nice('dvszwmarrgswjxmb')
  False
  """
    # It contains at least three vowels (aeiou only)
    if quantify(s, lambda c: c in 'aeiou') < 3:
        return False
    # It contains at least one letter that appears twice in a row
    if not pat.search(s):
        return False
    if any(bad in s for bad in ('ab', 'cd', 'pq', 'xy')):
        return False
    return True
Exemplo n.º 2
0
def nice(s, pat=re.compile(r'([a-z])\1')):
  """
  >>> nice('ugknbfddgicrmopn')
  True
  >>> nice('aaa')
  True
  >>> nice('jchzalrnumimnmhp')
  False
  >>> nice('haegwjzuvuyypxyu')
  False
  >>> nice('dvszwmarrgswjxmb')
  False
  """
  # It contains at least three vowels (aeiou only)
  if quantify(s, lambda c: c in 'aeiou') < 3:
    return False
  # It contains at least one letter that appears twice in a row
  if not pat.search(s):
    return False
  if any(bad in s for bad in ('ab', 'cd', 'pq', 'xy')):
    return False
  return True
Exemplo n.º 3
0
 def __init__(self, pk, name, amount, quantifier):
     self.pk = pk
     self.name = name
     self.balance = utils.quantify(amount, quantifier)
Exemplo n.º 4
0
 def modify_balance(self, amount, quantifier):
     money = utils.quantify(amount, quantifier)
     if self.balance + money < 0.0:
         raise BankruptError(self, money)
     else:
         self.balance += money
Exemplo n.º 5
0
 def pool_money(self, amount, quantifier):
     self.pooled_money += utils.quantify(amount, quantifier)
     print('total pooled money: ', self.pooled_money)