Words Score

Sort by

recency

|

158 Discussions

|

  • + 0 comments
    def is_vowel(letter):
        return letter in ['a', 'e', 'i', 'o', 'u', 'y']
    def score_words(words):
        score = 0
        for word in words:
            num_vowels = 0
            for letter in word:
                if is_vowel(letter):
                    num_vowels += 1
            if num_vowels % 2 == 0:
                score += 2
            else:
                score += 1
        return score
    
    n = int(input())
    words = input().split()
    print(score_words(words))
    
  • + 0 comments

    import sys

    def score_words(words): vowels = {'a','e','i','o','u','y'} score = 0 for word in words: vowels_count = sum(1 for i in word if i in vowels) if vowels_count%2==0: score = score+2 else: score = score+1 return score

    if name == "main": n = int(input()) word = input().split() words = [] for i in range(n): if len(word[i])<=20 and word[i].islower(): words.append(word[i]) print(score_words(words))

  • + 0 comments
    import re
    
    N = int(input())
    score = 0
    for i in input().split():
        if(len(re.findall(r"[aeiouy]", i)) %2 == 0):
            score += 2
        else:
            score += 1
    
    print(score)
    
  • + 0 comments

    just update the ++score to score += 1, because python does not supports the pre and post increment concepts.

  • + 0 comments

    Seriously ... 30 points for spotting ++score .

    Ps:

    def has_vowel(letters):
        v_sum =sum([['a', 'e', 'i', 'o', 'u', 'y'].count(l) for l in letters]) 
        return  2 if  v_sum %2 == 0 else 1    
    def score_words(words):
        return sum([has_vowel(w) for w in [[*map(str,word)] for word in words]])