<jupyter_start><jupyter_text>Challenge 1 capital indexes<jupyter_code>def capital_indexes(input_string: str) -> list:
    capital_indexes_list = []

    for index, i in enumerate(input_string):
        if i.isupper():
            capital_indexes_list.append(index)

    return capital_indexes_list<jupyter_output><empty_output><jupyter_text>Challenge 2 mid letter<jupyter_code>def mid(input_string):
    input_string_len = len(input_string)
    if (input_string_len % 2) == 0:
        return("")
    else:        
        #return input_string[int(((input_string_len + 1) / 2) - 1)]
        #floor division
        return input_string[input_string_len//2]
def mid_one_line(input_string):
    input_string_len = len(input_string)
    # statement if condition else statement     
    return input_string[input_string_len//2] if (input_string_len % 2) != 0 else ""<jupyter_output><empty_output><jupyter_text>Challenge 3 online statuses<jupyter_code>#  Dicts in Python
d = {"python": 3.8, "ubuntu": 20.04}
type(d)
assert d.get("pythonx") == None

for key,value in d.items():
    print("{} : {}".format(key,value))
def online_count(input_dict):
    online_count = 0
    for value in input_dict.values():
        if value == "online":
            online_count += 1
    return online_count<jupyter_output><empty_output><jupyter_text>Challenge 4 randomness<jupyter_code># random library
import random

# list(range(1,11, 2)

random.uniform(1,10.5)

import random
def random_number():
    # return random.randrange(1, 101)
    return random.randint(1,100)<jupyter_output><empty_output><jupyter_text>Challenge 5 type check<jupyter_code>def only_ints(a, b):
    return True if (type(a) == int and type(b) == int) else False<jupyter_output><empty_output><jupyter_text>Challenge 6 double letters<jupyter_code>def double_letters(input_string):
    if not input_string:
        return False
    for index, letter in enumerate(input_string):
        if letter == input_string[index+1]:
            return True
        if index == len(input_string) - 2:
            return False<jupyter_output><empty_output><jupyter_text>Challenge 7 adding and removing dots<jupyter_code>def add_dots(input_string):
    return ".".join(input_string)

def remove_dots(input_string):
    for i in input_string:
        return input_string.replace('.','')

add_dots("test")
assert remove_dots(add_dots("test")) == "test"<jupyter_output><empty_output><jupyter_text>Challenge 8 Counting syllables<jupyter_code>def count(input_string):
    return input_string.count("-") + 1
def count(input_string):
    return len(input_string.split("-"))<jupyter_output><empty_output><jupyter_text>Challenge 9 Anagrams<jupyter_code>def count_letters(string):
    return {i:string.count(i) for i in string}

    # for i in string:
    #     return string.count(i)

def is_anagram(a,b):
    return count_letters(a) == count_letters(b)
    # for i in a:
    #     if a.count(i) != b.count(i):
    #         return False
    # for i in b:
    #     if a.count(i) != b.count(i):
    #         return False
    # return True
count_letters("abcab")<jupyter_output><empty_output><jupyter_text>Challenge 10 Flatten a list<jupyter_code>def flatten(a):
    b=[]
    for i in a:
        for j in i:
            b.append(j)
    return b
# [[1,2], [3,4]]
def flatten(lists):
    return [i for inner_list in lists for i in inner_list]<jupyter_output><empty_output><jupyter_text>Challenge 11 Min-Maxing<jupyter_code>def largest_difference(a):
    return max(a)-min(a)<jupyter_output><empty_output><jupyter_text>Challenge 12 Divisible by 3<jupyter_code>def div_3(integer):
    return integer % 3 == 0<jupyter_output><empty_output><jupyter_text>Challenge 13 Tic tac toe input<jupyter_code># A0, A1, A2, A3
# a[0] : string
# a[1] : int

def get_row_col(a):
    mapping = {"A": 0, "B": 1, "C": 2}
    return (int(a[0]) -1, mapping[a[1]])<jupyter_output><empty_output><jupyter_text>Challenge 14 Palindrome<jupyter_code>def palindrome(a):
    # return a == a[::-1]
    a_list = list(a)
    a_list.reverse()
    return list(a) == a_list
l = [1,2,3]
l.reverse()
l<jupyter_output><empty_output><jupyter_text>Challenge 15 Up and down<jupyter_code>def up_down(input_integer):
    return input_integer - 1, input_integer + 1<jupyter_output><empty_output><jupyter_text>Challenge 16 Consecutive zeros<jupyter_code>def consecutive_zeros(binary_string):
    return max([len(i) for i in binary_string.split("1")])
consecutive_zeros("1001101000110")<jupyter_output><empty_output><jupyter_text>Challenge 17 All equal<jupyter_code>def all_equal(input_list):
    # for i in input_list:
    #     for j in input_list:
    #         if i != j:
    #             return False
    # return True
    return all([i == input_list[0] for i in input_list])
l = [1 for i in range(3)]
len(l)
# l.append(0)
l
all_equal(l)<jupyter_output><empty_output><jupyter_text>Challenge 19 Writing short code<jupyter_code># [int, int, int] ==map==> [str, str, str] 

def convert(input_list):
    return list(map(str ,input_list))
    
convert([1,2,3,4,5,6])<jupyter_output><empty_output><jupyter_text>Challenge  Custom zip<jupyter_code>def zap(a,b):
    res = []
    for i in range(len(a)):
        tup = (a[i], b[i])
        res.append(tup)
    return res

    # return [(a[i], b[i]) for i in range(len(a))]<jupyter_output><empty_output><jupyter_text>Challenge Solution Validation<jupyter_code>def validate(code):
    if 'def' not in code:
        return "missing def"
    if ':' not in code:
        return "missing :"
    if '(' + ')' in code:
        return "missing param"
    if '(' not in code or ')' not in code:
        return "missing paren"
    if '    ' not in code:
        return "missing indent"
    if 'validate' not in code:
        return "wrong name"
    if 'return' not in code:
        return "missing return"
    return True<jupyter_output><empty_output><jupyter_text>Challenge list xor<jupyter_code>def list_xor(n, list1, list2):
    # return (n in list1 or n in list2) and (n not in list1 or n not in list2)
    return (n in list1) ^ (n in list2)<jupyter_output><empty_output><jupyter_text>Challenge Counting parameters<jupyter_code>def func(input_a:int ,*argv, **kwargs):
    for arg in argv:
        print(arg)    
    for key, value in kwargs.items():
        print(key, value)


args = {"test", "python", 0}
kwargs = {"arg1": "test", "arg2": "python", "arg3": 0}


func(input_a = 0, **kwargs)

# func()
def param_count(*a):
    return len(a)<jupyter_output><empty_output><jupyter_text>Challenge Thousands separator<jupyter_code>def format_number(a):
    s=str(a)
    r=''
    j=0
    for i in s[::-1]:
        r+=str(i)
        j+=1
        if j%3==0:
            r+=','
    if len(s)%3==0:
        return r[-2::-1]
    return r[::-1]
# 1,000,000 ==> 00[0],000,1 ==> 1,000,000
def format_number(number):
    res = ""
    for i, num in enumerate(reversed(str(number))):
        if i != 0 and (i % 3) == 0:
            res += ","
        res += num
    return res[::-1]
format_number(1000000)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13452787258248008, 'fraction_numerical': 0.024032992036405007, 'mean_word_length': 3.867128027681661, 'pattern_counts': {'":': 9, '<': 93, '<?xml version=': 0, '>': 97, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '23', 'dir': 'jupyter-structured-clean-dedup', 'id': '421884', 'license': 'CC0-1.0', 'n_tokens_mistral': 2718, 'n_tokens_neox': 2571, 'n_words': 574, 'path': 'principles/main.ipynb', 'repo_name': '0xAliNik/CS-SBU-Py-Challenges', 'size': '7032'}