From 54e7d2597f2ab78df92c66108cd31f0bf215cb8d Mon Sep 17 00:00:00 2001
From: mezaadri <adrian.meza@adp.com>
Date: Thu, 15 Apr 2021 19:21:06 -0700
Subject: [PATCH] add Section 01-04 file edits (@adrianme213)

---
 Section_01/assignment_01.py |  2 ++
 Section_01/assignment_02.py |  1 +
 Section_01/assignment_03.py |  3 +++
 Section_01/assignment_04.py |  3 ++-
 Section_01/assignment_05.py |  4 +++-
 Section_03/assignment_05.py |  8 +++++++
 Section_04/assignment_01.py | 20 ++++++++++++++---
 Section_04/assignment_02.py | 12 +++++++++--
 Section_04/assignment_03.py | 18 +++++++++++++---
 Section_04/assignment_04.py | 12 +++++++++++
 Section_04/assignment_05.py | 15 +++++++++----
 Section_04/assignment_06.py | 12 +++++++++++
 Section_04/assignment_07.py | 13 +++++++++++
 Section_04/assignment_08.py | 43 ++++++++++++++++++-------------------
 Section_04/assignment_09.py | 19 ++++++++++++++++
 15 files changed, 149 insertions(+), 36 deletions(-)

diff --git a/Section_01/assignment_01.py b/Section_01/assignment_01.py
index fa1f33a..48ac0a4 100644
--- a/Section_01/assignment_01.py
+++ b/Section_01/assignment_01.py
@@ -5,6 +5,8 @@
     How would you change the code to meet the requirement?
 
 """
+rem = 15 % 4
+print(f"Remainder is {rem}.")
 
 
 
diff --git a/Section_01/assignment_02.py b/Section_01/assignment_02.py
index a5636d1..d1fbe2d 100644
--- a/Section_01/assignment_02.py
+++ b/Section_01/assignment_02.py
@@ -9,6 +9,7 @@
 
 """
 
+print("We have {0} small boxes, {1} large boxes, and {1} medium boxes".format(10, 12))
 
 
 
diff --git a/Section_01/assignment_03.py b/Section_01/assignment_03.py
index 5d312a7..6d84f95 100644
--- a/Section_01/assignment_03.py
+++ b/Section_01/assignment_03.py
@@ -21,6 +21,9 @@
 # Expected Result Printed: [[Cool]]
 
 # Your code below:
+floor_min = len(chars)//2
+result = chars[0:floor_min] + word + chars[floor_min:]
+print(f"{result}")
 
 
 
diff --git a/Section_01/assignment_04.py b/Section_01/assignment_04.py
index addb148..4e03abd 100644
--- a/Section_01/assignment_04.py
+++ b/Section_01/assignment_04.py
@@ -19,7 +19,8 @@
 # Expected Result Printed: omputerTuck
 
 # Your code below:
-
+result = word1[1:]+word2[0]+word2[2:]
+print(result)
 
 
 
diff --git a/Section_01/assignment_05.py b/Section_01/assignment_05.py
index d672da4..aaa6ae2 100644
--- a/Section_01/assignment_05.py
+++ b/Section_01/assignment_05.py
@@ -24,7 +24,9 @@
 
 # Your code below:
 
-
+floor_min = len(chars)//2
+result = chars[0:floor_min] + word + chars[floor_min:]
+print(f"{result}")
 
 
 
diff --git a/Section_03/assignment_05.py b/Section_03/assignment_05.py
index 425df0b..456858c 100644
--- a/Section_03/assignment_05.py
+++ b/Section_03/assignment_05.py
@@ -16,8 +16,16 @@
 # Your Code Below:
 
 
+def key_list_items(key, **kwargs):
+    my_dict = kwargs.get(key, None)
+    if (my_dict is None) or (len(my_dict) < 2):
+        return None
+    return my_dict[-2]
 
 
+sample = key_list_items("things", things=['tv'], people=['pete', 'mike', 'jan', 'tom'])
+print(' ---- ', sample)
+
 
 
 
diff --git a/Section_04/assignment_01.py b/Section_04/assignment_01.py
index f3313a1..f11617c 100644
--- a/Section_04/assignment_01.py
+++ b/Section_04/assignment_01.py
@@ -12,10 +12,24 @@
 
 """
 
-# Your Code Below:
-
-
 
+# Your Code Below:
+def twelver(one, two):
+    if (type(one) == int or type(one) == float) and (type(two) == int or type(two) == float):
+        pass
+    else:
+        return False
+
+    if one == 12 or two == 12 or one+two == 12:
+        return True
+    return False
+
+
+print(twelver(3, 12))
+print(twelver(4, 9))
+print(twelver(9, 3))
+print(twelver(5.5, 6.5))
+print(twelver("a", "1"))
 
 
 
diff --git a/Section_04/assignment_02.py b/Section_04/assignment_02.py
index d0dc7b5..22f9452 100644
--- a/Section_04/assignment_02.py
+++ b/Section_04/assignment_02.py
@@ -18,8 +18,16 @@
 """
 
 # Your Code Below:
-
-
+def pay_extra(working, hour):
+    if not working:
+        return False
+    if hour < 8 or hour > 20:
+        return True
+    return False
+
+print(pay_extra(True, 11))
+print(pay_extra(False, 5))
+print(pay_extra(True, 6))
 
 
 
diff --git a/Section_04/assignment_03.py b/Section_04/assignment_03.py
index 6d4d390..c18c44c 100644
--- a/Section_04/assignment_03.py
+++ b/Section_04/assignment_03.py
@@ -12,9 +12,21 @@
 """
 
 # Your Code Below:
-
-
-
+def sequence(my_list=[]):
+    if len(my_list) < 3:
+        return False
+
+    for ii in range(len(my_list)-2):
+        p1, p2, p3 = my_list[ii], my_list[ii+1], my_list[ii+2]
+        if p1 == 1 and p2 == 2 and p3 == 3:
+            return True
+    return False
+
+print(sequence([1,1,2,3,1]))
+print(sequence([1,1,2,4,1]))
+print(sequence([1,1,2,1,2,3]))
+print(sequence([1,2]))
+print(sequence([]))
 
 
 
diff --git a/Section_04/assignment_04.py b/Section_04/assignment_04.py
index b5940c4..e328283 100644
--- a/Section_04/assignment_04.py
+++ b/Section_04/assignment_04.py
@@ -12,7 +12,19 @@
 # Your Code Below:
 
 
+def grow_string(string):
+    if len(string) == 0:
+        return False
 
+    result = ""
+    for i in range(len(string)):
+        result += string[:i+1]
+    return result
+
+
+print(grow_string("Code") == "CCoCodCode")
+print(grow_string("abc") == "aababc")
+print(grow_string("ab") == "aab")
 
 
 
diff --git a/Section_04/assignment_05.py b/Section_04/assignment_05.py
index 3b61d70..7c09bb0 100644
--- a/Section_04/assignment_05.py
+++ b/Section_04/assignment_05.py
@@ -15,16 +15,23 @@
 
 # Your Code Below:
 
+def first3(my_list):
+    ii = 0
+    while ii < len(my_list) and ii < 4:
+        if my_list[ii] == 6:
+            return True
+        ii += 1
 
+    return False
 
 
 
 
 
-print(first3([1,2,6,3,0,0])) # true
-print(first3([1,2,3,3,0,6])) # false
-print(first3([6])) # true
-print(first3([])) # false
+print(first3([1,2,6,3,0,0]))
+print(first3([1,2,3,3,0,6]))
+print(first3([6]))
+print(first3([]))
 
 
 
diff --git a/Section_04/assignment_06.py b/Section_04/assignment_06.py
index 8219b61..084385f 100644
--- a/Section_04/assignment_06.py
+++ b/Section_04/assignment_06.py
@@ -17,12 +17,24 @@
 """
 
 # Your Code Below:
+def last2(my_str):
+    if len(my_str) <= 2:
+        return 0
+    one, two = my_str[-2], my_str[-1]
 
+    ii = 0
+    result = 0
+    while ii < len(my_str)-2:
+        if (my_str[ii] == one) and (my_str[ii+1] == two):
+            result += 1
+        ii += 1
 
+    return result
 
 print(last2('hixxhi')) #→ 1
 print(last2('xaxxaxaxx')) #→ 1
 print(last2('axxxxaaxx')) #→ 3
+print(last2('xxx')) #→ 1
 
 
 
diff --git a/Section_04/assignment_07.py b/Section_04/assignment_07.py
index 32484a0..507f584 100644
--- a/Section_04/assignment_07.py
+++ b/Section_04/assignment_07.py
@@ -14,10 +14,23 @@
 
 #Your Code Below:
 
+def string_match(str1, str2):
+    set1 = set()
+    for ii in range(len(str1)-1):
+        my_str = str1[ii]+str1[ii+1]
+        set1.add(my_str)
 
+    set2 = set()
+    for ii in range(len(str2)-1):
+        my_str = str2[ii]+str2[ii+1]
+        set2.add(my_str)
 
+    return len(set1.intersection(set2))
 
 
+print(string_match("xxcaazz", "xxbaaz") == 3)
+print(string_match("abc", "abc") == 2)
+print(string_match("abc", "axc") == 0)
 
 
 
diff --git a/Section_04/assignment_08.py b/Section_04/assignment_08.py
index 49ebe3d..b12b52b 100644
--- a/Section_04/assignment_08.py
+++ b/Section_04/assignment_08.py
@@ -15,28 +15,27 @@
 """
 
 #Your Code Below:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-print(sum78([1, 2, 2])) #→ 5
-print(sum78([1, 2, 2, 7, 99, 99, 8])) #→ 5
-print(sum78([1, 1, 7, 8, 2])) #→ 4
-
-
+def sum78(my_list):
+    if len(my_list) == 0:
+        return 0
+
+    new_list = []
+    ii = 0
+    while ii < len(my_list):
+        if my_list[ii] == 7:
+            while my_list[ii] != 8:
+                ii += 1
+        else:
+            new_list.append(my_list[ii])
+        ii += 1
+
+    return sum(new_list)
+
+print(sum78([1,2,2]) == 5)
+print(sum78([1,2,2,7,99,99,8]) == 5)
+print(sum78([1,1,7,8,2]) == 4)
+print(sum78([]) == 0)
+print(sum78([1]) == 1)
 
 
 
diff --git a/Section_04/assignment_09.py b/Section_04/assignment_09.py
index d3150d2..1cf10f6 100644
--- a/Section_04/assignment_09.py
+++ b/Section_04/assignment_09.py
@@ -38,12 +38,31 @@
 
 # Your Code Below:
 # --------------------------------------
+max = 0
+for key in d:
+    cur_num = int(d[key])
+    if cur_num > max:
+        max = cur_num
 
 
+for cur_str in fr:
+    str_split = cur_str.split("|")
+    email = str_split[0]
+    is_in_d = d.get(email, None)
+    if is_in_d is None:
+        max += 1
+        d[email] = str(max)
 
 
+def replace_email_with_val(my_str):
+    str_split = my_str.split("|")
+    email = str_split[0]
+    str_split[0] = d.get(email)
+    return "|".join(str_split)
 
 
+fr = list(map(replace_email_with_val, fr))
+
 # don't change the lines below:
 # --------------------------------------
 print("Value of fr: ")
