From 7d40fd9d4cba54fefff75bb16a3586c99661ed5a Mon Sep 17 00:00:00 2001 From: DSAghicha Date: Wed, 22 Dec 2021 23:08:21 +0530 Subject: [PATCH 01/28] Solution for #01 --- December-01/python3_dsaghicha.py | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 December-01/python3_dsaghicha.py diff --git a/December-01/python3_dsaghicha.py b/December-01/python3_dsaghicha.py new file mode 100644 index 0000000..bb2f5b2 --- /dev/null +++ b/December-01/python3_dsaghicha.py @@ -0,0 +1,38 @@ +# #1 Elegant Facelift +# @Author: DSAghicha (Darshaan Aghicha) + +def common_char(all_str: list[str]) -> int: + """ + Identifies common characters in words of a list. + + Keyword Arguments: + all_str: List of words + + Returns number of letters repeated. + """ + rep_letters: int = 0 + limit: int = len(all_str) + char_dict: dict[str: list[int]] = {} + + for word in all_str: + unique: set[str] = set(word) + for letter in unique: + occurrence: int = word.count(letter) + try: + char_dict[letter].append(occurrence) + except KeyError: + char_dict[letter] = [occurrence] + + for key in char_dict: + if len(char_dict[key]) == limit: + rep_letters += 1 + return rep_letters + + +def main(): + words: list = [word for word in input("Enter space separated list of stones: ").split()] + print(common_char(words)) + + +if __name__ == '__main__': + main() From 8beae6bd646351e681138708fef347dfd0061f71 Mon Sep 17 00:00:00 2001 From: DSAghicha Date: Thu, 23 Dec 2021 00:37:08 +0530 Subject: [PATCH 02/28] Solution for #02 --- December-02/python3_dsaghicha.py | 37 ++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 December-02/python3_dsaghicha.py diff --git a/December-02/python3_dsaghicha.py b/December-02/python3_dsaghicha.py new file mode 100644 index 0000000..eee8039 --- /dev/null +++ b/December-02/python3_dsaghicha.py @@ -0,0 +1,37 @@ +# #02 Bingo! +# @DSAghicha (Darshaan Aghicha) + +def sum_of_squares(number: int) -> None: + """ + Calculates sum of square of digits in the number, and calls itself until condition fails. + Conditions: + - number is not a positive integer. (prints "NO") + - sum = 1. (prints "YES") + Args: + number: int + Returns: + None + """ + if number > 0: + num: list[int] = [int(n) for n in str(number)] + sum_num: int = 0 + for n in num: + sum_num += n ** 2 + try: + if sum_num != 1: + sum_of_squares(sum_num) + else: + print("YES") + except RecursionError: + print("NO") + else: + print("NO") + + +def main() -> None: + num: int = int(input("Enter the Number: ")) + sum_of_squares(num) + + +if __name__ == '__main__': + main() From 063950b68f943bd43003d94ff43fdb1936b86048 Mon Sep 17 00:00:00 2001 From: DSAghicha Date: Mon, 27 Dec 2021 20:04:01 +0530 Subject: [PATCH 03/28] Solution for #3 --- December-03/python3_dsaghicha.py | 56 ++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 December-03/python3_dsaghicha.py diff --git a/December-03/python3_dsaghicha.py b/December-03/python3_dsaghicha.py new file mode 100644 index 0000000..7c612c9 --- /dev/null +++ b/December-03/python3_dsaghicha.py @@ -0,0 +1,56 @@ +# #03 Lotto! +# @DSAghicha (Darshaan Aghicha) +def search_grid(board: list[list[str]], name: str) -> bool: + ROW, COL = len(board), len(board[0]) + path = set() + + def search(row, col, i): + if i == len(name): + return True + + if (row < 0 or col < 0 or row >= ROW or col >= COL or name[i] != board[row][col] or (row, col) in path): + False + + path.add((row, col)) + + result = (search(row + 1, col, i + 1) or search(row - 1, col, i + 1) or search(row, col + 1, i + 1) or search(row, col - 1, i + 1)) + + return result + + for row in range(ROW): + for col in range(COL): + if search(row, col, 0): + return True + + return False + + +def main(): + try: + R: int = int(input("Enter the number of rows: ")) + C: int = int(input("Enter the number of columns: ")) + matrix: list[list[str]] = [] + + for _i in range(C): + letters: list[str] = input(f"Enter {R} letters (space seperated): ").split(' ') + + while len(letters) != R: + print("\nIt seems like you missed some letters!\n") + letters: list[str] = input(f"Re-enter {R} letters (space seperated): ").split(' ') + matrix.append([letter.upper() for letter in letters]) + + word: str = input("Enter word to be searched: ") + while len(word) < 2: + print("Please input a proper word!") + word: str = input("Re-enter word to be searched: ") + + print(search_grid(matrix, word.upper())) + except ValueError: + print("It was not a number!\n\n") + main() + + +if __name__ == "__main__": + # grid: list[list[str]] = [["D","J","O","G"],["W","B","H","S"],["T","Z","N","E"]] + # print(search_grid(grid, name="JOHN")) + main() From cd33ff667f4741826376b66922b36ada5d4a35a5 Mon Sep 17 00:00:00 2001 From: DSAghicha Date: Mon, 27 Dec 2021 23:22:01 +0530 Subject: [PATCH 04/28] Solution for #05 --- December-05/python3_dsaghicha.py | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 December-05/python3_dsaghicha.py diff --git a/December-05/python3_dsaghicha.py b/December-05/python3_dsaghicha.py new file mode 100644 index 0000000..50ee631 --- /dev/null +++ b/December-05/python3_dsaghicha.py @@ -0,0 +1,33 @@ +# #05 Biscuit Bonanza! +# @DSAghicha (Darshaan Aghicha) +def check(customers: list[int], biscuits: list[int]) -> None: + if not customers or not biscuits or biscuits[0] not in customers: + print(f"Customers that are unable to eat = {len(customers)}") + return + + if customers[0] == biscuits[0]: + customers.pop(0) + biscuits.pop(0) + # print(f"Front customer takes the top biscuit and leaves the line making customers = {customers} and biscuits = {biscuits}.") + else: + first_item = customers[0] + customers.pop(0) + customers.append(first_item) + # print(f"Front customer leaves the top biscuit and returns to the end of the line making customers = {customers}.") + check(customers, biscuits) + + +def main() -> None: + try: + customers: list[int] = [int(choice) for choice in input("Enter customers choice (space separated): ").split(' ')] + biscuits: list[int] = [int(choice) for choice in input("Enter biscuits choice (space separated): ").split(' ')] + check(customers, biscuits) + except ValueError: + print("One or more values were not integer!") + + +if __name__ == '__main__': + # customers = [1,1,0,0,1,0] + # biscuits = [0,1,0,1,1,1] + # check(customers, biscuits) + main() From c0be6f0be1f7d13638c25a2a29ba9eec3dd72871 Mon Sep 17 00:00:00 2001 From: DSAghicha Date: Wed, 29 Dec 2021 20:29:31 +0530 Subject: [PATCH 05/28] Solution for #06 --- December-06/python3_dsaghicha.py | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 December-06/python3_dsaghicha.py diff --git a/December-06/python3_dsaghicha.py b/December-06/python3_dsaghicha.py new file mode 100644 index 0000000..b92d290 --- /dev/null +++ b/December-06/python3_dsaghicha.py @@ -0,0 +1,36 @@ +# #06 Save The Templars! +# @DSAghicha (Darshaan Aghicha) +def swaps(data: list[str]) -> int: + total: int = data.count('T') + curTemplars: int = 0 + + for i in range(total): + if data[i] == 'T': + curTemplars += 1 + + ans = curTemplars + + for i in range(total, len(data)): + if data[i] == 'T': + curTemplars += 1 + + if data[i - total] == 'T': + curTemplars -= 1 + + ans = min(ans, curTemplars) + + return ans + +def main() -> None: + arrangement: list[str] = list(input("Enter arrangement sequence: ")) + if arrangement: + arrangement = [i.upper() for i in arrangement] + print(swaps(arrangement)) + else: + print("You didn't provide the sequence!!\n\nLet's try again") + main() + + + +if __name__ == '__main__': + main() From 4eb84ccffbf16a5881dd110a41a78239fb0cf032 Mon Sep 17 00:00:00 2001 From: DSAghicha Date: Wed, 29 Dec 2021 23:53:58 +0530 Subject: [PATCH 06/28] Solution for #10 --- December-10/python3_dsaghicha.py | 80 ++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 December-10/python3_dsaghicha.py diff --git a/December-10/python3_dsaghicha.py b/December-10/python3_dsaghicha.py new file mode 100644 index 0000000..0902698 --- /dev/null +++ b/December-10/python3_dsaghicha.py @@ -0,0 +1,80 @@ +# #03 Juicy Orange Field! +# @DSAghicha (Darshaan Aghicha) +class Solution: + def __init__(self, size: int, field: list[list[int]]) -> None: + # * Starting Position (0, 0) + self.x, self.y = 0, 0 + # * Destination Position + self.X, self.Y = size - 1, size - 1 + self.field = field + self.oranges = 0 + + def move_in(self) -> None: + if self.y != self.Y: + right_cell: int = self.field[self.x][self.y + 1] + + if right_cell == 1: + self.oranges += 1 + self.field[self.x][self.y + 1] = 0 + if right_cell == 1 or right_cell == 0: + self.y += 1 + return + if self.x != self.X: + down_cell: int = self.field[self.x + 1][self.y] + + if down_cell == 1: + self.oranges += 1 + self.field[self.x + 1][self.y] = 0 + if down_cell == 1 or down_cell == 0: + self.x += 1 + return + + def move_out(self) -> None: + if self.Y != 0: + right_cell: int = self.field[self.X][self.Y - 1] + + if right_cell == 1: + self.oranges += 1 + self.field[self.X][self.Y - 1] = 0 + if right_cell == 1 or right_cell == 0: + self.Y -= 1 + return + if self.X != 0: + down_cell: int = self.field[self.X - 1][self.Y] + + if down_cell == 1: + self.oranges += 1 + self.field[self.X - 1][self.Y] = 0 + if down_cell == 1 or down_cell == 0: + self.X -= 1 + return + + def start(self) -> int: + while (self.x, self.y) != (self.X, self.Y): + self.move_in() + while ((self.X, self.Y)) != (0, 0): + self.move_out() + return self.oranges + + + +def main() -> None: + try: + n = int(input("Enter maze size: ")) + field: list[list[int]] = [] + for _i in range(n): + row: list[int] = [int(cell) for cell in input(f"Enter {n} cells (space seperated): ").split(' ')] + for cell in row: + if cell not in [0, 1, -1]: + print(cell) + print("Invalid Input!") + main() + + field.append(row) + print(Solution(n, field).start()) + except ValueError: + print("It was not a number!\n\n") + main() + +if __name__ == "__main__": + main() From f441269ccea4d3622a22aa8087296d02a9d6185a Mon Sep 17 00:00:00 2001 From: DSAghicha Date: Wed, 29 Dec 2021 23:55:22 +0530 Subject: [PATCH 07/28] Solution for #10 --- December-10/python3_dsaghicha.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/December-10/python3_dsaghicha.py b/December-10/python3_dsaghicha.py index 0902698..482d194 100644 --- a/December-10/python3_dsaghicha.py +++ b/December-10/python3_dsaghicha.py @@ -1,4 +1,4 @@ -# #03 Juicy Orange Field! +# #10 Juicy Orange Field! # @DSAghicha (Darshaan Aghicha) class Solution: def __init__(self, size: int, field: list[list[int]]) -> None: From 270ad0f28ab9068b9d6d212c4cb3826f27255cd5 Mon Sep 17 00:00:00 2001 From: DSAghicha Date: Thu, 30 Dec 2021 01:32:59 +0530 Subject: [PATCH 08/28] Solution for #12 --- December-12/python3_dsaghicha.py | 44 ++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 December-12/python3_dsaghicha.py diff --git a/December-12/python3_dsaghicha.py b/December-12/python3_dsaghicha.py new file mode 100644 index 0000000..590f75b --- /dev/null +++ b/December-12/python3_dsaghicha.py @@ -0,0 +1,44 @@ +# #12 Ford vs Ferrari! +# @DSAghicha (Darshaan Aghicha) +def superiority(arr: list[int]) -> None: + if len(arr) <= 1: + return arr + + cars = req_split(arr) + for i in range(len(cars)): + if cars[i][0] == '-': + if cars[i][1] < cars[i - 1][1]: + arr.pop(i) + superiority(arr) + elif cars[i][1] == cars[i - 1][1]: + arr.pop(i) + arr.pop(i - 1) + superiority(arr) + else: + arr.pop(i - 1) + superiority(arr) + + return arr + + +def req_split(arr: list[int]) -> list[str, int]: + final_arr = [] + for num in arr: + if num < 0: + cell = ['-', int(str(num)[1])] + else: + cell = ['+', num] + final_arr.append(cell) + return final_arr + + +def main() -> None: + try: + cars: list[int] = [int(car) for car in input("Enter the row of cars: ").split(' ')] + print(superiority(cars)) + except ValueError: + print("One or more cars were not correct!\n\n") + main() + +if __name__ == "__main__": + main() From c52570888c3626ff2855758a2987334fb74a7c90 Mon Sep 17 00:00:00 2001 From: DSAghicha Date: Sat, 1 Jan 2022 18:29:12 +0530 Subject: [PATCH 09/28] Solution for #08 --- December-08/python3_dsaghicha.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 December-08/python3_dsaghicha.py diff --git a/December-08/python3_dsaghicha.py b/December-08/python3_dsaghicha.py new file mode 100644 index 0000000..22ef858 --- /dev/null +++ b/December-08/python3_dsaghicha.py @@ -0,0 +1,31 @@ +# #08 Anomalous Counter! +# @DSAghicha (Darshaan Aghicha) +def counter_value(timer: int) -> int: + if timer == 0: + return 0 + + counter_dial: int = 0 + prev_dial: int = 0 + cycle_dial: int = 0 + counter = 0 + while timer > counter_dial: + counter += 1 + prev_dial = counter_dial + counter_dial = counter_dial + 3 * (2 ** cycle_dial) + cycle_dial += 1 + + return 3 * (2 ** (cycle_dial - 1)) - (timer - prev_dial) + 1 + + + +def main() -> None: + try: + time: int = int(input("Enter time: ")) + value: int = counter_value(time) + print(f"Counter value = {value}") + except ValueError: + print("I expected a number!!\n\n") + main() + +if __name__ == "__main__": + main() From 8b14ab5f52de85c2d5fa53ca0e4cb98cfb940441 Mon Sep 17 00:00:00 2001 From: DSAghicha Date: Sun, 2 Jan 2022 00:45:21 +0530 Subject: [PATCH 10/28] Solution for #07 --- December-07/python3_dsaghicha.py | 58 ++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 December-07/python3_dsaghicha.py diff --git a/December-07/python3_dsaghicha.py b/December-07/python3_dsaghicha.py new file mode 100644 index 0000000..87d1efa --- /dev/null +++ b/December-07/python3_dsaghicha.py @@ -0,0 +1,58 @@ +# #07 Amy helps Pawnee! +# @DSAghicha (Darshaan Aghicha) +def no_building(building_co: list[list[int]],axis: str, axis_no: int) -> list[int]: + axis_rep: int = 0 if (axis == 'x') else 1 + success: int = 0 + + for i in range(len(building_co)): + lt: bool = False + gt: bool = False + for j in range(axis_rep, 6, 2): + if building_co[i][j] < axis_no: + lt = True + elif building_co[i][j] > axis_no: + gt = True + + if lt and gt: success += 1 + + return success + +def main() -> None: + try: + successful_buildings: list[int] = [] + + # ? Getting Building Info + n: int = int(input("Enter number of buildings: ")) + coordinates: list[list[int]] = [] + print("Enter coordinates of the buildings:\n(Press Enter to enter coordinates of next building)") + for _ in range(n): + c: list[int] = [int(i) for i in input().split(' ')] + if len(c) == 6: + coordinates.append(c) + else: + print("You entered invalid number of coordinates!") + print("Each building must contain six coordinates\na1 b1 a2 b2 a3 b3\n\n") + main() + + # ? Getting Plane Info + jet_planes = int(input("Enter number of jet-planes: ")) + print("Enter axis and its coordinate (space separated):\n(Press Enter to enter coordinates of next plane)") + for _ in range(jet_planes): + c: list[str, int] = input().split() + if c[0] in ['x', 'y']: + units: int = no_building(coordinates, c[0], int(c[1])) + successful_buildings.append(units) + else: + print("Axis need to be X or Y!\n\n") + main() + + # ? Printing Values + print("Buildings that received food:", *successful_buildings, sep= " ") + except ValueError: + print("I expected a number!!\n\n") + main() + + +if __name__ == "__main__": + main() + # no_building([[1, 0, 0, 2, 2, 2], [1, 3, 3, 5, 4, 0], [5, 4, 4, 5, 4, 4]], 'x', 2) From 48df4644b9a3566730164569211915162d3067ce Mon Sep 17 00:00:00 2001 From: DSAghicha Date: Sun, 2 Jan 2022 00:46:36 +0530 Subject: [PATCH 11/28] Rectified return type of function --- December-07/python3_dsaghicha.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/December-07/python3_dsaghicha.py b/December-07/python3_dsaghicha.py index 87d1efa..ae4a404 100644 --- a/December-07/python3_dsaghicha.py +++ b/December-07/python3_dsaghicha.py @@ -1,6 +1,6 @@ # #07 Amy helps Pawnee! # @DSAghicha (Darshaan Aghicha) -def no_building(building_co: list[list[int]],axis: str, axis_no: int) -> list[int]: +def no_building(building_co: list[list[int]],axis: str, axis_no: int) -> int: axis_rep: int = 0 if (axis == 'x') else 1 success: int = 0 From ba42b482929368e20211e70010a2384e60089b78 Mon Sep 17 00:00:00 2001 From: DSAghicha Date: Sun, 2 Jan 2022 22:01:41 +0530 Subject: [PATCH 12/28] Solution for #13 --- December-13/python3_dsaghicha.py | 55 ++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 December-13/python3_dsaghicha.py diff --git a/December-13/python3_dsaghicha.py b/December-13/python3_dsaghicha.py new file mode 100644 index 0000000..a228eaf --- /dev/null +++ b/December-13/python3_dsaghicha.py @@ -0,0 +1,55 @@ +# #13 Desert Shopping! +# @DSAghicha (Darshaan Aghicha) +def sales(clients:int, diamonds:int, diamond_eval: list[list[int]], client_req: list[list[int]]) -> None: + sales:int = [] + t = 0 + for j in range(clients): + print(f"k{j} = {client_req[j][0]}, r{j} = {client_req[j][1]}") + for p in range(diamonds): + print(f"m{p} = {diamond_eval[p][0]}, n{p} = {diamond_eval[p][1]}") + print() + + for client in range(clients): + interested:int = 0 + for diamond in range(diamonds): + purity: bool = client_req[client][0] < diamond_eval[diamond][0] + cost: bool = client_req[client][1] >= diamond_eval[diamond][1] + print(purity, cost) + if purity and cost: + interested += 1 + t += 1 + + sales.append(interested) + + print(sales) + print("T: ", t) + print(f"Maximum number of diamonds sold = {max(sales)}") + + +def main() -> None: + try: + x: int = int(input("Enter number of unsold diamonds: ")) + diamond_eval: list[list[int]] = [] + client_req: list[list[int]] = [] + z: int = int(input("Enter number of clients: ")) + + for j in range(z): + kj: int = int(input(f"Enter client {j}'s requested purity level: ")) + rj: int = int(input(f"Enter client {j}'s price: ")) + client_req.append([kj, rj]) + + for p in range(x): + mp: int = int(input(f"Enter diamond {p}'s purity level: ")) + np: int = int(input(f"Enter diamond {p}'s minimum price: ")) + diamond_eval.append([mp, np]) + + print(z, x, diamond_eval, client_req) + sales(z, x, diamond_eval, client_req) + except ValueError: + print("I expected a number!!\n\n") + main() + + +if __name__ == "__main__": + main() + \ No newline at end of file From 31796244c0c95661d59bec19ec198817d0dbe0be Mon Sep 17 00:00:00 2001 From: DSAghicha Date: Sun, 2 Jan 2022 22:03:27 +0530 Subject: [PATCH 13/28] Revert "Solution for #13" This reverts commit ba42b482929368e20211e70010a2384e60089b78. --- December-13/python3_dsaghicha.py | 55 -------------------------------- 1 file changed, 55 deletions(-) delete mode 100644 December-13/python3_dsaghicha.py diff --git a/December-13/python3_dsaghicha.py b/December-13/python3_dsaghicha.py deleted file mode 100644 index a228eaf..0000000 --- a/December-13/python3_dsaghicha.py +++ /dev/null @@ -1,55 +0,0 @@ -# #13 Desert Shopping! -# @DSAghicha (Darshaan Aghicha) -def sales(clients:int, diamonds:int, diamond_eval: list[list[int]], client_req: list[list[int]]) -> None: - sales:int = [] - t = 0 - for j in range(clients): - print(f"k{j} = {client_req[j][0]}, r{j} = {client_req[j][1]}") - for p in range(diamonds): - print(f"m{p} = {diamond_eval[p][0]}, n{p} = {diamond_eval[p][1]}") - print() - - for client in range(clients): - interested:int = 0 - for diamond in range(diamonds): - purity: bool = client_req[client][0] < diamond_eval[diamond][0] - cost: bool = client_req[client][1] >= diamond_eval[diamond][1] - print(purity, cost) - if purity and cost: - interested += 1 - t += 1 - - sales.append(interested) - - print(sales) - print("T: ", t) - print(f"Maximum number of diamonds sold = {max(sales)}") - - -def main() -> None: - try: - x: int = int(input("Enter number of unsold diamonds: ")) - diamond_eval: list[list[int]] = [] - client_req: list[list[int]] = [] - z: int = int(input("Enter number of clients: ")) - - for j in range(z): - kj: int = int(input(f"Enter client {j}'s requested purity level: ")) - rj: int = int(input(f"Enter client {j}'s price: ")) - client_req.append([kj, rj]) - - for p in range(x): - mp: int = int(input(f"Enter diamond {p}'s purity level: ")) - np: int = int(input(f"Enter diamond {p}'s minimum price: ")) - diamond_eval.append([mp, np]) - - print(z, x, diamond_eval, client_req) - sales(z, x, diamond_eval, client_req) - except ValueError: - print("I expected a number!!\n\n") - main() - - -if __name__ == "__main__": - main() - \ No newline at end of file From c7ff516ed2bfb074db33dc10c051cd6297b54bfb Mon Sep 17 00:00:00 2001 From: DSAghicha Date: Sun, 2 Jan 2022 22:05:44 +0530 Subject: [PATCH 14/28] Solution for #13 --- December-13/python3_dsaghicha.py | 43 ++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 December-13/python3_dsaghicha.py diff --git a/December-13/python3_dsaghicha.py b/December-13/python3_dsaghicha.py new file mode 100644 index 0000000..6f528dc --- /dev/null +++ b/December-13/python3_dsaghicha.py @@ -0,0 +1,43 @@ +# #13 Desert Shopping! +# @DSAghicha (Darshaan Aghicha) +def sales(clients:int, diamonds:int, diamond_eval: list[list[int]], client_req: list[list[int]]) -> None: + sales:int = [] + + for client in range(clients): + interested:int = 0 + for diamond in range(diamonds): + purity: bool = client_req[client][0] < diamond_eval[diamond][0] + cost: bool = client_req[client][1] >= diamond_eval[diamond][1] + if purity and cost: + interested += 1 + + sales.append(interested) + print(f"Maximum number of diamonds sold = {max(sales)}") + + +def main() -> None: + try: + x: int = int(input("Enter number of unsold diamonds: ")) + diamond_eval: list[list[int]] = [] + client_req: list[list[int]] = [] + z: int = int(input("Enter number of clients: ")) + + for j in range(z): + kj: int = int(input(f"Enter client {j}'s requested purity level: ")) + rj: int = int(input(f"Enter client {j}'s price: ")) + client_req.append([kj, rj]) + + for p in range(x): + mp: int = int(input(f"Enter diamond {p}'s purity level: ")) + np: int = int(input(f"Enter diamond {p}'s minimum price: ")) + diamond_eval.append([mp, np]) + + sales(z, x, diamond_eval, client_req) + except ValueError: + print("I expected a number!!\n\n") + main() + + +if __name__ == "__main__": + main() + \ No newline at end of file From fc8b5fae54d7e13d5a2b9a1e9995cc5ab425102b Mon Sep 17 00:00:00 2001 From: DSAghicha Date: Tue, 4 Jan 2022 01:19:58 +0530 Subject: [PATCH 15/28] Solution for #14 --- December-14/python3_dsaghicha.py | 35 ++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 December-14/python3_dsaghicha.py diff --git a/December-14/python3_dsaghicha.py b/December-14/python3_dsaghicha.py new file mode 100644 index 0000000..caa0484 --- /dev/null +++ b/December-14/python3_dsaghicha.py @@ -0,0 +1,35 @@ +# #14 The Math Test! +# @DSAghicha (Darshaan Aghicha) +def no_concepts(chapters: list[int], hours) -> int: + total = sum(chapters) + concepts = total // hours if total % hours == 0 else (total // hours) + 1 + hour = 0 + + while True: + for chapter in chapters: + hour += chapter // concepts if chapter % concepts == 0 else (chapter // concepts) + 1 + + if hour == hours: + return concepts + + concepts += 1 + hour = 0 + + + + + +def main() -> None: + try: + n: list[int] = [int(N) for N in input("Enter chapters: (space separated) ").split(" ")] + x: int = int(input("Enter number of hours to prepare for the exam: ")) + + concepts = no_concepts(n, x) + print(f"She can study {concepts} concepts from her chapters per hour such that, she can cover all the concepts from the chapters within {x} hours.") + except ValueError: + print("Not a Number!!") + main() + + +if __name__ == "__main__": + main() From ba1a3ad665bcc253751c6c37ad2c8ea263ec1a8b Mon Sep 17 00:00:00 2001 From: DSAghicha Date: Tue, 4 Jan 2022 01:24:13 +0530 Subject: [PATCH 16/28] Revert "Solution for #14" This reverts commit fc8b5fae54d7e13d5a2b9a1e9995cc5ab425102b. --- December-14/python3_dsaghicha.py | 35 -------------------------------- 1 file changed, 35 deletions(-) delete mode 100644 December-14/python3_dsaghicha.py diff --git a/December-14/python3_dsaghicha.py b/December-14/python3_dsaghicha.py deleted file mode 100644 index caa0484..0000000 --- a/December-14/python3_dsaghicha.py +++ /dev/null @@ -1,35 +0,0 @@ -# #14 The Math Test! -# @DSAghicha (Darshaan Aghicha) -def no_concepts(chapters: list[int], hours) -> int: - total = sum(chapters) - concepts = total // hours if total % hours == 0 else (total // hours) + 1 - hour = 0 - - while True: - for chapter in chapters: - hour += chapter // concepts if chapter % concepts == 0 else (chapter // concepts) + 1 - - if hour == hours: - return concepts - - concepts += 1 - hour = 0 - - - - - -def main() -> None: - try: - n: list[int] = [int(N) for N in input("Enter chapters: (space separated) ").split(" ")] - x: int = int(input("Enter number of hours to prepare for the exam: ")) - - concepts = no_concepts(n, x) - print(f"She can study {concepts} concepts from her chapters per hour such that, she can cover all the concepts from the chapters within {x} hours.") - except ValueError: - print("Not a Number!!") - main() - - -if __name__ == "__main__": - main() From 335f97ae9b5adc63eb39f0e15615bd657470b34f Mon Sep 17 00:00:00 2001 From: DSAghicha Date: Tue, 4 Jan 2022 01:26:41 +0530 Subject: [PATCH 17/28] Solution for #14 --- December-14/python3_dsaghicha.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 December-14/python3_dsaghicha.py diff --git a/December-14/python3_dsaghicha.py b/December-14/python3_dsaghicha.py new file mode 100644 index 0000000..5056146 --- /dev/null +++ b/December-14/python3_dsaghicha.py @@ -0,0 +1,32 @@ +# #14 The Math Test! +# @DSAghicha (Darshaan Aghicha) +def no_concepts(chapters: list[int], hours) -> int: + total = sum(chapters) + concepts = total // hours if total % hours == 0 else (total // hours) + 1 + hour = 0 + + while True: + for chapter in chapters: + hour += chapter // concepts if chapter % concepts == 0 else (chapter // concepts) + 1 + + if hour == hours: + return concepts + + concepts += 1 + hour = 0 + + +def main() -> None: + try: + n: list[int] = [int(N) for N in input("Enter chapters: (space separated) ").split(" ")] + x: int = int(input("Enter number of hours to prepare for the exam: ")) + + concepts = no_concepts(n, x) + print(f"She can study {concepts} concepts from her chapters per hour such that, she can cover all the concepts from the chapters within {x} hours.") + except ValueError: + print("Not a Number!!") + main() + + +if __name__ == "__main__": + main() \ No newline at end of file From 43a186fd12b2b0671c92994357770fe662133f3b Mon Sep 17 00:00:00 2001 From: DSAghicha Date: Tue, 4 Jan 2022 02:19:55 +0530 Subject: [PATCH 18/28] Revert "Not supportable @ 3.10" This reverts commit 335f97ae9b5adc63eb39f0e15615bd657470b34f. --- December-14/python3_dsaghicha.py | 32 -------------------------------- 1 file changed, 32 deletions(-) delete mode 100644 December-14/python3_dsaghicha.py diff --git a/December-14/python3_dsaghicha.py b/December-14/python3_dsaghicha.py deleted file mode 100644 index 5056146..0000000 --- a/December-14/python3_dsaghicha.py +++ /dev/null @@ -1,32 +0,0 @@ -# #14 The Math Test! -# @DSAghicha (Darshaan Aghicha) -def no_concepts(chapters: list[int], hours) -> int: - total = sum(chapters) - concepts = total // hours if total % hours == 0 else (total // hours) + 1 - hour = 0 - - while True: - for chapter in chapters: - hour += chapter // concepts if chapter % concepts == 0 else (chapter // concepts) + 1 - - if hour == hours: - return concepts - - concepts += 1 - hour = 0 - - -def main() -> None: - try: - n: list[int] = [int(N) for N in input("Enter chapters: (space separated) ").split(" ")] - x: int = int(input("Enter number of hours to prepare for the exam: ")) - - concepts = no_concepts(n, x) - print(f"She can study {concepts} concepts from her chapters per hour such that, she can cover all the concepts from the chapters within {x} hours.") - except ValueError: - print("Not a Number!!") - main() - - -if __name__ == "__main__": - main() \ No newline at end of file From 8a07e7c98bc05afb1d8daa095db34e037be4ad59 Mon Sep 17 00:00:00 2001 From: DSAghicha Date: Tue, 4 Jan 2022 02:24:00 +0530 Subject: [PATCH 19/28] Solution for #14 --- December-14/python3_dsaghicha.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 December-14/python3_dsaghicha.py diff --git a/December-14/python3_dsaghicha.py b/December-14/python3_dsaghicha.py new file mode 100644 index 0000000..9449fa2 --- /dev/null +++ b/December-14/python3_dsaghicha.py @@ -0,0 +1,32 @@ +# #14 The Math Test! +# @DSAghicha (Darshaan Aghicha) +def no_concepts(chapters: list[int], hours) -> int: + total: int = sum(chapters) + concepts: int = total // hours if total % hours == 0 else (total // hours) + 1 + + while True: + hour: int = 0 + + for chapter in chapters: + hour += chapter // concepts if chapter % concepts == 0 else (chapter // concepts) + 1 + + if hour == hours: + return concepts + + concepts += 1 + + +def main() -> None: + try: + n: list[int] = [int(N) for N in input("Enter chapters: (space separated) ").split(" ")] + x: int = int(input("Enter number of hours to prepare for the exam: ")) + + concepts = no_concepts(n, x) + print(f"She can study {concepts} concepts from her chapters per hour such that, she can cover all the concepts from the chapters within {x} hours.") + except ValueError: + print("Not a Number!!") + main() + + +if __name__ == "__main__": + main() \ No newline at end of file From c87e812224728c45c1dc72875c2964e155a61244 Mon Sep 17 00:00:00 2001 From: DSAghicha Date: Tue, 4 Jan 2022 02:52:50 +0530 Subject: [PATCH 20/28] Solution for #09 --- December-09/python3_dsaghicha.py | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 December-09/python3_dsaghicha.py diff --git a/December-09/python3_dsaghicha.py b/December-09/python3_dsaghicha.py new file mode 100644 index 0000000..2433ef1 --- /dev/null +++ b/December-09/python3_dsaghicha.py @@ -0,0 +1,33 @@ +# #09 Dream 11! +# @DSAghicha (Darshaan Aghicha) +def base_number(p:int, aptitude_ratings: list[int]) -> int: + revised_ratings: list[int] = [aptitude_ratings[i] for i in range(p)] + num1: int = revised_ratings[len(revised_ratings) - 1] + ans: int = 0 + for i in range(len(revised_ratings) - 2, -1, -1): + ans += (num1 - revised_ratings[i]) + + return ans + + +def main() -> None: + try: + n: int = int(input("Enter number of understudies (n): ")) + p: int = int(input("Enter number of understudies you wish to pick (p): ")) + if n < 0 or p > n: + raise Exception + ar: list[int] = [int(N) for N in input(f"Enter the aptitude rating of {n} understudies (space separated): ").split(' ')] + sorted(ar) + + print(f"Base number of periods required = {base_number(p, ar)}") + + except ValueError: + print("I expected a number!!\n\n") + main() + except Exception: + print("Invalid Inputs!!\n\n") + main() + + +if __name__ == "__main__": + main() From b908411fbaf41a2175ebdb1d8b01249182fe7f31 Mon Sep 17 00:00:00 2001 From: DSAghicha Date: Fri, 7 Jan 2022 16:58:21 +0530 Subject: [PATCH 21/28] Solution for #15 --- December-15/python3_dsaghicha.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 December-15/python3_dsaghicha.py diff --git a/December-15/python3_dsaghicha.py b/December-15/python3_dsaghicha.py new file mode 100644 index 0000000..6b92c33 --- /dev/null +++ b/December-15/python3_dsaghicha.py @@ -0,0 +1,24 @@ +# Twinkling Bracelets! +# @DSAghicha (Darshaan Aghicha) +def bracelets_per_day(no_bracelets: list[int], days: int) -> int: + max_value: int = max(-1, max(no_bracelets)) + for i in range(max_value, sum(no_bracelets)): + bracelets: int = sum(no_bracelets) // i + if sum(no_bracelets) % i != 0: + bracelets += 1 + if bracelets <= days: + return i + + +def main() -> None: + try: + bracelets: int = [int(bracelet) for bracelet in input("Enter number of bracelets (space separated): ").split(" ")] + no_days:int = int(input("Enter maximum number of n days for the bracelets to be delivered to the customers: ")) + print(f'\nPinky can make {bracelets_per_day(bracelets, no_days)} bracelets and deliver them in a day such that she delivers all the orders within {no_days} days.\n') + except ValueError: + print("Improper input!!") + main() + + +if __name__ == "__main__": + main() \ No newline at end of file From d2effd2b7bae2dddcf5f6a70d0877844062682c6 Mon Sep 17 00:00:00 2001 From: DSAghicha Date: Fri, 7 Jan 2022 17:01:12 +0530 Subject: [PATCH 22/28] refractor: Added EOF --- December-15/python3_dsaghicha.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/December-15/python3_dsaghicha.py b/December-15/python3_dsaghicha.py index 6b92c33..9175ba1 100644 --- a/December-15/python3_dsaghicha.py +++ b/December-15/python3_dsaghicha.py @@ -21,4 +21,4 @@ def main() -> None: if __name__ == "__main__": - main() \ No newline at end of file + main() From 905763cc69e141f245af62b9c384e7ac47ecdd35 Mon Sep 17 00:00:00 2001 From: DSAghicha Date: Sun, 9 Jan 2022 20:30:03 +0530 Subject: [PATCH 23/28] Solution for #16 --- December-16/python3_dsaghicha.py | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 December-16/python3_dsaghicha.py diff --git a/December-16/python3_dsaghicha.py b/December-16/python3_dsaghicha.py new file mode 100644 index 0000000..34e601c --- /dev/null +++ b/December-16/python3_dsaghicha.py @@ -0,0 +1,33 @@ +# Catch Me If You Can! +# @DSAghicha (Darshaan Aghicha) +def leos_fate(X: int, A: int, a: list[int]): + odd_pos = even_pos = 0 + for pos in a: + if pos % 2 == 0: + even_pos += 1 + else: + odd_pos += 1 + + if odd_pos == 0 or even_pos == 0: + return (X, 1) + else: + return (odd_pos, -1) if odd_pos > even_pos else (even_pos, -1) + + +def main() -> None: + try: + no_ranger: int = int(input("Enter number of rangers (X): ")) + leo_pos: int = int(input("Enter position of Leo (A): ")) + ranger_pos: list[int] = [int(x) for x in input("Enter position of ranger(s): ").split(" ")] + + fallen_ranger, fate = leos_fate(no_ranger, leo_pos, ranger_pos) + + fate_str: str = "and he escapes" if fate == 1 else "but gets caught" + print(f"Leo can eliminate {fallen_ranger} ranger(s) {fate_str}.") + print(f"{fallen_ranger} {fate}") + + except ValueError: + print("Invalid Input!") + +if __name__ == "__main__": + main() From c1e24086c9924fbce6efac8081512e850069ddf4 Mon Sep 17 00:00:00 2001 From: DSAghicha Date: Sun, 9 Jan 2022 23:49:05 +0530 Subject: [PATCH 24/28] Solution for #17 --- December-17/python3_dsaghicha.py | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 December-17/python3_dsaghicha.py diff --git a/December-17/python3_dsaghicha.py b/December-17/python3_dsaghicha.py new file mode 100644 index 0000000..9d3517d --- /dev/null +++ b/December-17/python3_dsaghicha.py @@ -0,0 +1,38 @@ +""" +@title: The Bossy Manager +@author: DSAghicha (Darshaan Aghicha) +@access: public +""" +def min_time(task_size, processing_time, no_tasks) -> int: + min_time: int = 0 + time: int = 0 # Time for each single task + size: int = len(task_size) + for i in range(size): + time = no_tasks[i] // task_size[i] + if no_tasks[i] % task_size[i] != 0: time += 1 + min_time = max(min_time, (time * processing_time[i])) + + return min_time + + +def main() -> None: + try: + task_size: list[int] = [int(x) for x in input("Enter task size (space separated): ").split(" ")] + processing_time: list[int] = [int(x) for x in input("Enter processing time (space separated): ").split(" ")] + no_tasks: list[int] = [int(x) for x in input("Enter number of tasks (space separated): ").split(" ")] + if len(task_size) != len(processing_time) != no_tasks: + raise Exception + + req_time: int = min_time(task_size, processing_time, no_tasks) + print(f"The minimun time to process all the tasks is {req_time}.") + except ValueError: + print("Invalid Input") + main() + + except Exception: + print("\nIt seems like you skipped one or more values.\nLet's try again!\n") + main() + + +if __name__ == "__main__": + main() From ad770d25c62b2926d5b1a57a5d68f12f341bc92c Mon Sep 17 00:00:00 2001 From: DSAghicha Date: Mon, 10 Jan 2022 00:43:05 +0530 Subject: [PATCH 25/28] Solution for #18 --- December-18/python3_dsaghicha.py | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 December-18/python3_dsaghicha.py diff --git a/December-18/python3_dsaghicha.py b/December-18/python3_dsaghicha.py new file mode 100644 index 0000000..b1caedd --- /dev/null +++ b/December-18/python3_dsaghicha.py @@ -0,0 +1,38 @@ +""" +@title: Connections +@author: DSAghicha (Darshaan Aghicha) +@access: public +""" +def connections(matrix: list[list[int]]) -> int: + n: int = len(matrix) # Size of Matrix + least_connections: int = 0 + x, y = None, None + + for i in range(n): + for j in range(n): + if matrix[i][j] == 1: + if x is None: + x, y = i, j + else: + least_connections += abs(x - i) + abs(y - j) + + return least_connections - 1 + +def main() -> None: + try: + grid: list[list[int]] = [] + size: int = int(input("Enter Grid Size: ")) + print("Enter Matrix: (space separated for row, Enter for new column)") + for num in range(size): + col: list[int] = [int(x) for x in input().split(" ")] + if len(col) != size: + raise ValueError + grid.append(col) + print(f"You must flip at least {connections(grid)} 0(s) to connect the two houses.") + + except ValueError: + print("\nInvalid input!\n") + main() + +if __name__ == "__main__": + main() From 208d45ec8b22c31bd86841a9a38c43137af5b5f2 Mon Sep 17 00:00:00 2001 From: DSAghicha Date: Mon, 10 Jan 2022 02:21:38 +0530 Subject: [PATCH 26/28] Solution for #19 --- December-19/python3_dsaghicha.py | 61 ++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 December-19/python3_dsaghicha.py diff --git a/December-19/python3_dsaghicha.py b/December-19/python3_dsaghicha.py new file mode 100644 index 0000000..dc6dd28 --- /dev/null +++ b/December-19/python3_dsaghicha.py @@ -0,0 +1,61 @@ +""" +@title: Winter is coming +@author: DSAghicha (Darshaan Aghicha) +@access: public +""" +def mandatory_courses(course: list[list[int]],answer: list[list[int]]) -> tuple[list[bool], int]: + result: list[bool] = [] + indirect_dependency: list[int] = [] + indirect_index: int = -1 + for i in range(len(course)): + if i + 1 < len(course) and course[i][1] == course[i+1][0]: + pr: list[int] = [course[i][0], course[i+1][1]] + indirect_dependency = pr if pr not in course else [] + + for answers in answer: + if indirect_dependency == answers: + indirect_index = answer.index(answers) + result.append(True) + else: + result.append(answers in course) + return (result, indirect_index) + + +def main() -> None: + try: + num: int = int(input("Enter number of courses: ")) + courses: list[list[int]] = [] + for _ in range(num - 1): + print("Enter course: ", end='') + course = [int(x) for x in input().split(" ")] + if len(course) != 2: + raise ValueError + courses.append(course) + + answers: list[list[int]] = [] + for _ in range(2): + print("Enter answer: ", end='') + answer = [int(x) for x in input().split(" ")] + if len(answer) != 2: + raise ValueError + answers.append(answer) + output, format_index = mandatory_courses(courses, answers) + print(f"Output: {output}") + print(f"\n{'-' * 10}\n") + for i in range(len(answers)): + if format_index == i: + print(format_index) + print(f"Course {answers[i][0]} is mandatory to take up course {answers[i][1]}.") + + elif output[i] is True: + print(f"Course {answers[i][0]} is mandatory to take up course {answers[i][1]}.") + elif output[i] is False: + print(f"Course {answers[i][0]} is not mandatory to take up course {answers[i][1]}.") + + except ValueError: + print("\nInvalid Input!\n") + main() + + +if __name__ == "__main__": + main() From ce76a47286ca86f71c7429f1304761c860320a16 Mon Sep 17 00:00:00 2001 From: DSAghicha Date: Mon, 10 Jan 2022 02:25:56 +0530 Subject: [PATCH 27/28] bug: Removed Safe Check --- December-19/python3_dsaghicha.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/December-19/python3_dsaghicha.py b/December-19/python3_dsaghicha.py index dc6dd28..ba20608 100644 --- a/December-19/python3_dsaghicha.py +++ b/December-19/python3_dsaghicha.py @@ -3,10 +3,9 @@ @author: DSAghicha (Darshaan Aghicha) @access: public """ -def mandatory_courses(course: list[list[int]],answer: list[list[int]]) -> tuple[list[bool], int]: +def mandatory_courses(course: list[list[int]],answer: list[list[int]]) -> list[bool]: result: list[bool] = [] indirect_dependency: list[int] = [] - indirect_index: int = -1 for i in range(len(course)): if i + 1 < len(course) and course[i][1] == course[i+1][0]: pr: list[int] = [course[i][0], course[i+1][1]] @@ -14,11 +13,10 @@ def mandatory_courses(course: list[list[int]],answer: list[list[int]]) -> tuple[ for answers in answer: if indirect_dependency == answers: - indirect_index = answer.index(answers) result.append(True) else: result.append(answers in course) - return (result, indirect_index) + return result def main() -> None: @@ -39,15 +37,11 @@ def main() -> None: if len(answer) != 2: raise ValueError answers.append(answer) - output, format_index = mandatory_courses(courses, answers) + output = mandatory_courses(courses, answers) print(f"Output: {output}") print(f"\n{'-' * 10}\n") for i in range(len(answers)): - if format_index == i: - print(format_index) - print(f"Course {answers[i][0]} is mandatory to take up course {answers[i][1]}.") - - elif output[i] is True: + if output[i] is True: print(f"Course {answers[i][0]} is mandatory to take up course {answers[i][1]}.") elif output[i] is False: print(f"Course {answers[i][0]} is not mandatory to take up course {answers[i][1]}.") From 4a9cdc3be79ca8cbc4daf4a26e3b3fe28ed67985 Mon Sep 17 00:00:00 2001 From: DSAghicha Date: Mon, 10 Jan 2022 20:26:51 +0530 Subject: [PATCH 28/28] Solution for #21 --- December-21/python3_dsaghicha.py | 59 ++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 December-21/python3_dsaghicha.py diff --git a/December-21/python3_dsaghicha.py b/December-21/python3_dsaghicha.py new file mode 100644 index 0000000..ba230c6 --- /dev/null +++ b/December-21/python3_dsaghicha.py @@ -0,0 +1,59 @@ +""" +@title: Transform to Checkerboard +@author: DSAghicha (Darshaan Aghicha) +@access: public +""" +from collections import Counter + + +def moves_to_checkerboard(initial_board: list[list[int]]) -> int: + n: int = len(initial_board) # Size of the Board + inverted_board: list[list[int]] = [[row[i] for row in initial_board] for i in range(n)] + row_count = list(Counter([tuple(row) for row in initial_board]).items()) + col_count = list(Counter([tuple(row) for row in inverted_board]).items()) + + if len(row_count) != 2 or len(col_count) != 2: + return -1 # Task is impossible!!! + + h_pattern = list([1, 0] * ((n // 2) + 1))[:n] + l_pattern = list([0, 1] * ((n // 2) + 1))[:n] + + # Number of ROWS needed to be flipped + nr1: int = sum([1 for i in range(n) if row_count[0][0][i] != h_pattern[i]]) + nr2: int = sum([1 for i in range(n) if row_count[0][0][i] != l_pattern[i]]) + + # Number of COLUMNS needed to be flipped + nc1: int = sum([1 for i in range(n) if col_count[0][0][i] != h_pattern[i]]) + nc2: int = sum([1 for i in range(n) if col_count[0][0][i] != l_pattern[i]]) + + # Checking if required number of Rows & Columns is EVEN + nr = [x for x in (nr1, nr2) if x % 2 == 0] + nc = [x for x in (nc1, nc2) if x % 2 == 0] + + return int(min(nr) // 2 + min(nc) // 2) + + + +def main() -> None: + try: + board: list[list[int]] = [] + n: int = int(input("Enter size of your board: ")) + print(f"Enter a {n} x {n} board:\n(Hit Enter for next column and each number should be space separated)") + for col in range(n): + row = [int(num) for num in input().split()] + + other_number = False + for elem in row: + if elem not in [1, 0]: other_number = True + if len(row) != n or other_number: raise ValueError + + board.append(row) + + print(moves_to_checkerboard(board)) + except ValueError: + print("Invalid Input!") + main() + + +if __name__ == "__main__": + main()