<commit_before># question 4 (unit 2) number of odd seven digit integers with non-repeating
# characters, using list comprehension from this week's class.

def question1():

    lst = [x for x in range (0,9999999) for char in str(x) if (x % 2 == 1)
       and str(x).count(char)==1]
    return(len(lst))

# PyCharm CE can convert the list comprehension to for loop for cross-check

def question1_var():
    lst = []
    for x in range(0, 9999999):
        for char in str(x):
            if (x % 2 == 1) and str(x).count(char) == 1:
                lst.append(x)
    return(len(lst))
<commit_msg>Pythonic solutions to assorted questions from the first STA247 assignment<commit_after># question 4 (unit 2) number of odd seven digit integers with non-repeating
# characters, using list comprehension from this week's class.


def question1():

    # lst = {x for x in range (0,9999999) for char in str(x) if (x % 2 == 1)
    #   and str(x).count(char)==1}

    # this list comprehension adds an item to the list if it is odd
    # and if no character in the string occurs greater than once.
    lst = [x for x in range(0, 10000000) if (x % 2 == 1)
           and all([0 for char in list(str(x)) if str(x).count(char) > 1])]
    return len(lst)

# PyCharm CE can convert the list comprehension to for loop for cross-check


def question1_var():

    lst2 = [x for x in range(0, 10000000)]
    count = 0
    for num in lst2:
        if num % 2 == 1 and len(str(num)) == len(set(list(str(num)))):
            count += 1
    return count


import time
start_time = time.time()

print("initial list comprehension approach", question1())
print("--- %s seconds ---" % (time.time() - start_time))
print("second set and list length approach", question1_var())
print("--- %s seconds ---" % (time.time() - start_time))
print("here's my paper solution", 10*9*8*7*6*5*2)
print("--- %s seconds ---" % (time.time() - start_time))
{'fraction_non_alphanumeric': 0.13396127681841968, 'fraction_numerical': 0.042909471480900054, 'mean_word_length': 3.068085106382979, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 5, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5235937', 'n_tokens_mistral': 684, 'n_tokens_neox': 608, 'n_words': 243}