From 7e642130d16aab56a157a121fba7b4947e7c0d78 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:21 +0000 Subject: [PATCH 01/74] [Sync Iteration] python/hello-world/1 --- solutions/python/hello-world/1/hello_world.py | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 solutions/python/hello-world/1/hello_world.py diff --git a/solutions/python/hello-world/1/hello_world.py b/solutions/python/hello-world/1/hello_world.py new file mode 100644 index 00000000000..10b02a545b8 --- /dev/null +++ b/solutions/python/hello-world/1/hello_world.py @@ -0,0 +1,4 @@ +def hello(): + return 'Hello, World!' + +hello() From cb2e0e3dcbfe2c75dc4defd40ff4db8378dd0145 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:22 +0000 Subject: [PATCH 02/74] [Sync Iteration] python/armstrong-numbers/1 --- .../python/armstrong-numbers/1/armstrong_numbers.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 solutions/python/armstrong-numbers/1/armstrong_numbers.py diff --git a/solutions/python/armstrong-numbers/1/armstrong_numbers.py b/solutions/python/armstrong-numbers/1/armstrong_numbers.py new file mode 100644 index 00000000000..96b4c021082 --- /dev/null +++ b/solutions/python/armstrong-numbers/1/armstrong_numbers.py @@ -0,0 +1,9 @@ +def is_armstrong_number(number): + digits = str(number) + len_digits = len(digits) + sum_of_digits = 0 + for digit in digits: + sum_of_digits += pow(int(digit), len_digits) + if number == sum_of_digits: + return True + return False From ff43466961cd1bc66bba0d112ef14292fb32a6a1 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:22 +0000 Subject: [PATCH 03/74] [Sync Iteration] python/matrix/1 --- solutions/python/matrix/1/matrix.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 solutions/python/matrix/1/matrix.py diff --git a/solutions/python/matrix/1/matrix.py b/solutions/python/matrix/1/matrix.py new file mode 100644 index 00000000000..852bd8e6b07 --- /dev/null +++ b/solutions/python/matrix/1/matrix.py @@ -0,0 +1,17 @@ +class Matrix: + def __init__(self, matrix_string): + self.matrix_string = matrix_string + + def row(self, index): + tab = self.matrix_string.split("\n") + return list(map(int, tab[index-1].split(" "))) + + def column(self, index): + tab_col = self.matrix_string.split("\n") + tableau = [] + for i in range(len(tab_col)): + tableau.append(list(map(int, tab_col[i].split(" ")))) + result = [] + for j in range(len(tableau)): + result.append(tableau[j][index-1]) + return result From 52e18ab9a2966666582c95367c9b0a8cc7940ba2 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:23 +0000 Subject: [PATCH 04/74] [Sync Iteration] python/matrix/2 --- solutions/python/matrix/2/matrix.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 solutions/python/matrix/2/matrix.py diff --git a/solutions/python/matrix/2/matrix.py b/solutions/python/matrix/2/matrix.py new file mode 100644 index 00000000000..4eaf97f1f16 --- /dev/null +++ b/solutions/python/matrix/2/matrix.py @@ -0,0 +1,16 @@ +class Matrix: + def __init__(self, matrix_string): + self.matrix_string = matrix_string.split("\n") + + def row(self, index): + return list(map(int, self.matrix_string[index-1].split(" "))) + + def column(self, index): + tab_col = self.matrix_string.split("\n") + tableau = [] + for i in range(len(tab_col)): + tableau.append(list(map(int, tab_col[i].split(" ")))) + result = [] + for j in range(len(tableau)): + result.append(tableau[j][index-1]) + return result From 079e739f6d6e419fad033387094cd31d6392d60a Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:23 +0000 Subject: [PATCH 05/74] [Sync Iteration] python/matrix/3 --- solutions/python/matrix/3/matrix.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 solutions/python/matrix/3/matrix.py diff --git a/solutions/python/matrix/3/matrix.py b/solutions/python/matrix/3/matrix.py new file mode 100644 index 00000000000..3202cf1e5fb --- /dev/null +++ b/solutions/python/matrix/3/matrix.py @@ -0,0 +1,15 @@ +class Matrix: + def __init__(self, matrix_string): + self.matrix_string = matrix_string.split("\n") + + def row(self, index): + return list(map(int, self.matrix_string[index-1].split(" "))) + + def column(self, index): + tableau = [] + for i in range(len(self.matrix_string)): + tableau.append(list(map(int, self.matrix_string[i].split(" ")))) + result = [] + for j in range(len(tableau)): + result.append(tableau[j][index-1]) + return result From fc88f8ac78f053c3b58970cde9f806eed121f441 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:24 +0000 Subject: [PATCH 06/74] [Sync Iteration] python/matrix/4 --- solutions/python/matrix/4/matrix.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 solutions/python/matrix/4/matrix.py diff --git a/solutions/python/matrix/4/matrix.py b/solutions/python/matrix/4/matrix.py new file mode 100644 index 00000000000..59c56297a45 --- /dev/null +++ b/solutions/python/matrix/4/matrix.py @@ -0,0 +1,13 @@ +class Matrix: + def __init__(self, matrix_string): + self.matrix_string = matrix_string.split("\n") + + def row(self, index): + return list(map(int, self.matrix_string[index-1].split(" "))) + + def column(self, index): + tableau = [] + for i in range(len(self.matrix_string)): + tableau.append(list(map(int, self.matrix_string[i].split(" ")))) + + return [tableau[j][index-1] for j in range(len(tableau))] From b521ba4aa37b08deb5472fd303b99c3c55c4a6f1 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:24 +0000 Subject: [PATCH 07/74] [Sync Iteration] python/two-fer/1 --- solutions/python/two-fer/1/two_fer.py | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 solutions/python/two-fer/1/two_fer.py diff --git a/solutions/python/two-fer/1/two_fer.py b/solutions/python/two-fer/1/two_fer.py new file mode 100644 index 00000000000..efd49d14dde --- /dev/null +++ b/solutions/python/two-fer/1/two_fer.py @@ -0,0 +1,5 @@ +""" Two Fer """ +def two_fer(name): + if name != None: + return f"One for {name}, one for me." + return "One for you, one for me." From 5855f05ceaa9bdc3a55b988af7d6d90402696104 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:25 +0000 Subject: [PATCH 08/74] [Sync Iteration] python/two-fer/2 --- solutions/python/two-fer/2/two_fer.py | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 solutions/python/two-fer/2/two_fer.py diff --git a/solutions/python/two-fer/2/two_fer.py b/solutions/python/two-fer/2/two_fer.py new file mode 100644 index 00000000000..ab9de762405 --- /dev/null +++ b/solutions/python/two-fer/2/two_fer.py @@ -0,0 +1,3 @@ +""" Two Fer """ +def two_fer(name='you'): + return f"One for {name}, one for me." From 28a2d3e11027af47ce4c2a2a4cb6ff1e172156c6 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:25 +0000 Subject: [PATCH 09/74] [Sync Iteration] python/raindrops/1 --- solutions/python/raindrops/1/raindrops.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 solutions/python/raindrops/1/raindrops.py diff --git a/solutions/python/raindrops/1/raindrops.py b/solutions/python/raindrops/1/raindrops.py new file mode 100644 index 00000000000..c85e2d6e466 --- /dev/null +++ b/solutions/python/raindrops/1/raindrops.py @@ -0,0 +1,17 @@ +""" Raindrops """ +def convert(number): + if number % 3 == 0 and number % 5 == 0 and number % 7 == 0: + return "PlingPlangPlong" + if number % 3 == 0 and number % 5 == 0: + return "PlingPlang" + if number % 3 == 0 and number % 7 == 0: + return "PlingPlong" + if number % 5 == 0 and number % 7 == 0: + return "PlangPlong" + if number % 7 == 0: + return "Plong" + if number % 5 == 0: + return "Plang" + if number % 3 == 0: + return "Pling" + return str(number) From 16dfe778c8cab2f382fd11d099180bcdee18b11d Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:25 +0000 Subject: [PATCH 10/74] [Sync Iteration] python/raindrops/2 --- solutions/python/raindrops/2/raindrops.py | 29 +++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 solutions/python/raindrops/2/raindrops.py diff --git a/solutions/python/raindrops/2/raindrops.py b/solutions/python/raindrops/2/raindrops.py new file mode 100644 index 00000000000..7993c2a8901 --- /dev/null +++ b/solutions/python/raindrops/2/raindrops.py @@ -0,0 +1,29 @@ +""" Raindrops """ + +def convert(number): + resultat = "" + tableau = [(3, "Pling"), (5, "Plang"), (7, "Plong")] + for i, son in tableau: + print(i,son) + if number % i == 0: + resultat += son + if resultat == "": + return str(number) + else: + return resultat + + # if number % 3 == 0 and number % 5 == 0 and number % 7 == 0: + # return "PlingPlangPlong" + # if number % 3 == 0 and number % 5 == 0: + # return "PlingPlang" + # if number % 3 == 0 and number % 7 == 0: + # return "PlingPlong" + # if number % 5 == 0 and number % 7 == 0: + # return "PlangPlong" + # if number % 7 == 0: + # return "Plong" + # if number % 5 == 0: + # return "Plang" + # if number % 3 == 0: + # return "Pling" + # return str(number) From 02c9816c6e80c5b96f59602575870b9b0c61f296 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:26 +0000 Subject: [PATCH 11/74] [Sync Iteration] python/raindrops/3 --- solutions/python/raindrops/3/raindrops.py | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 solutions/python/raindrops/3/raindrops.py diff --git a/solutions/python/raindrops/3/raindrops.py b/solutions/python/raindrops/3/raindrops.py new file mode 100644 index 00000000000..67cd9bc1eda --- /dev/null +++ b/solutions/python/raindrops/3/raindrops.py @@ -0,0 +1,28 @@ +""" Raindrops """ + +def convert(number): + resultat = "" + tableau = [(3, "Pling"), (5, "Plang"), (7, "Plong")] + for i, son in tableau: + if number % i == 0: + resultat += son + if resultat == "": + return str(number) + else: + return resultat + + # if number % 3 == 0 and number % 5 == 0 and number % 7 == 0: + # return "PlingPlangPlong" + # if number % 3 == 0 and number % 5 == 0: + # return "PlingPlang" + # if number % 3 == 0 and number % 7 == 0: + # return "PlingPlong" + # if number % 5 == 0 and number % 7 == 0: + # return "PlangPlong" + # if number % 7 == 0: + # return "Plong" + # if number % 5 == 0: + # return "Plang" + # if number % 3 == 0: + # return "Pling" + # return str(number) From 56f4cfeb3f60c0950918b0e789380a01b4ee539b Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:26 +0000 Subject: [PATCH 12/74] [Sync Iteration] python/raindrops/4 --- solutions/python/raindrops/4/raindrops.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 solutions/python/raindrops/4/raindrops.py diff --git a/solutions/python/raindrops/4/raindrops.py b/solutions/python/raindrops/4/raindrops.py new file mode 100644 index 00000000000..386a735c5a4 --- /dev/null +++ b/solutions/python/raindrops/4/raindrops.py @@ -0,0 +1,12 @@ +""" Raindrops """ + +def convert(number): + resultat = "" + tableau = [(3, "Pling"), (5, "Plang"), (7, "Plong")] + for i, son in tableau: + if number % i == 0: + resultat += son + if resultat == "": + return str(number) + else: + return resultat From cfe664d79a7bb0cbe8f85c2c98e96fd354bfb9a3 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:26 +0000 Subject: [PATCH 13/74] [Sync Iteration] python/high-scores/1 --- solutions/python/high-scores/1/high_scores.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 solutions/python/high-scores/1/high_scores.py diff --git a/solutions/python/high-scores/1/high_scores.py b/solutions/python/high-scores/1/high_scores.py new file mode 100644 index 00000000000..02dc269e2b3 --- /dev/null +++ b/solutions/python/high-scores/1/high_scores.py @@ -0,0 +1,13 @@ +""" High Scores """ +def latest(scores): + return scores[-1] + + +def personal_best(scores): + scores.sort() + return scores[-1] + + +def personal_top_three(scores): + new_scores = sorted(scores, reverse=True) + return new_scores[:3] From f4356bedc7a29de8535594ee31b9761741a69cd6 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:27 +0000 Subject: [PATCH 14/74] [Sync Iteration] python/little-sisters-vocab/1 --- .../python/little-sisters-vocab/1/strings.py | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 solutions/python/little-sisters-vocab/1/strings.py diff --git a/solutions/python/little-sisters-vocab/1/strings.py b/solutions/python/little-sisters-vocab/1/strings.py new file mode 100644 index 00000000000..5d9bd084acb --- /dev/null +++ b/solutions/python/little-sisters-vocab/1/strings.py @@ -0,0 +1,69 @@ +def add_prefix_un(word): + """ + + :param word: str of a root word + :return: str of root word with un prefix + + This function takes `word` as a parameter and + returns a new word with an 'un' prefix. + """ + + return "un" + word + + +def make_word_groups(vocab_words): + """ + + :param vocab_words: list of vocabulary words with a prefix. + :return: str of prefix followed by vocabulary words with + prefix applied, separated by ' :: '. + + This function takes a `vocab_words` list and returns a string + with the prefix and the words with prefix applied, separated + by ' :: '. + """ + if (len(vocab_words) > 3): + prefix = vocab_words[0] + words = vocab_words[1:] + prefix_group = [] + for word in words: + new_word = prefix + word + prefix_group.append(new_word) + + return " :: ".join(prefix_group) + + +def remove_suffix_ness(word): + """ + + :param word: str of word to remove suffix from. + :return: str of word with suffix removed & spelling adjusted. + + This function takes in a word and returns the base word with `ness` removed. + """ + + word = word.rstrip("ness") + lettres = word.split("") + voyelles = ['a', 'e', 'i', 'o', 'u', 'y', 'A', 'E', 'I', '0', 'U', 'Y'] + for voyelle in voyelles: + if ((lettres[-1] == 'i') & (lettres[-2] != voyelle)): + lettres[-1] = "y" + word = "".join(lettres) + return word + + +def noun_to_verb(sentence, index): + """ + + :param sentence: str that uses the word in sentence + :param index: index of the word to remove and transform + :return: str word that changes the extracted adjective to a verb. + + A function takes a `sentence` using the + vocabulary word, and the `index` of the word once that sentence + is split apart. The function should return the extracted + adjective as a verb. + """ + + words = sentence.slpit(" ") + return words[index] + 'en' From cb0c89b5768c26b3008d4a55f2ee16711e9fee44 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:27 +0000 Subject: [PATCH 15/74] [Sync Iteration] python/little-sisters-vocab/2 --- .../python/little-sisters-vocab/2/strings.py | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 solutions/python/little-sisters-vocab/2/strings.py diff --git a/solutions/python/little-sisters-vocab/2/strings.py b/solutions/python/little-sisters-vocab/2/strings.py new file mode 100644 index 00000000000..f275f5ad84a --- /dev/null +++ b/solutions/python/little-sisters-vocab/2/strings.py @@ -0,0 +1,88 @@ +def add_prefix_un(word): + """ + + :param word: str of a root word + :return: str of root word with un prefix + + This function takes `word` as a parameter and + returns a new word with an 'un' prefix. + """ + + return "un" + word + + +def make_word_groups(vocab_words): + """ + + :param vocab_words: list of vocabulary words with a prefix. + :return: str of prefix followed by vocabulary words with + prefix applied, separated by ' :: '. + + This function takes a `vocab_words` list and returns a string + with the prefix and the words with prefix applied, separated + by ' :: '. + """ + if (len(vocab_words) > 3): + prefix = vocab_words[0] + words = vocab_words[1:] + prefix_group = [] + for word in words: + new_word = prefix + word + prefix_group.append(new_word) + + return " :: ".join(prefix_group) + + +def remove_suffix_ness(word): + """ + + :param word: str of word to remove suffix from. + :return: str of word with suffix removed & spelling adjusted. + + This function takes in a word and returns the base word with `ness` removed. + """ + + word = word.rstrip("ness") + lettres = list(word) + voyelles = ['a', 'e', 'i', 'o', 'u', 'y', 'A', 'E', 'I', '0', 'U', 'Y'] + for voyelle in voyelles: + if ((lettres[-1] == 'i') & (lettres[-2] != voyelle)): + lettres[-1] = "y" + word = "".join(lettres) + return word + + +def noun_to_verb(sentence, index): + """ + + :param sentence: str that uses the word in sentence + :param index: index of the word to remove and transform + :return: str word that changes the extracted adjective to a verb. + + A function takes a `sentence` using the + vocabulary word, and the `index` of the word once that sentence + is split apart. The function should return the extracted + adjective as a verb. + """ + + words = sentence.split() + return words[index] + 'en' + + +add_prefix_un("happy") + +add_prefix_un("manageable") + +make_word_groups(['en', 'close', 'joy', 'lighten']) + +make_word_groups(['pre', 'serve', 'dispose', 'position']) + +make_word_groups(['auto', 'didactic', 'graph', 'mate']) + +remove_suffix_ness("heaviness") + +remove_suffix_ness("sadness") + +noun_to_verb('I need to make that bright.', -1 ) + +noun_to_verb('It got dark as the sun set.', 2) \ No newline at end of file From 120f2c1ecfb1ad0a16b480f7e118d0a4ebb4d2e7 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:28 +0000 Subject: [PATCH 16/74] [Sync Iteration] python/little-sisters-vocab/3 --- .../python/little-sisters-vocab/3/strings.py | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 solutions/python/little-sisters-vocab/3/strings.py diff --git a/solutions/python/little-sisters-vocab/3/strings.py b/solutions/python/little-sisters-vocab/3/strings.py new file mode 100644 index 00000000000..8f55d95be82 --- /dev/null +++ b/solutions/python/little-sisters-vocab/3/strings.py @@ -0,0 +1,71 @@ +def add_prefix_un(word): + """ + + :param word: str of a root word + :return: str of root word with un prefix + + This function takes `word` as a parameter and + returns a new word with an 'un' prefix. + """ + + return "un" + word + + +def make_word_groups(vocab_words): + """ + + :param vocab_words: list of vocabulary words with a prefix. + :return: str of prefix followed by vocabulary words with + prefix applied, separated by ' :: '. + + This function takes a `vocab_words` list and returns a string + with the prefix and the words with prefix applied, separated + by ' :: '. + """ + if (len(vocab_words) > 3): + prefix = vocab_words[0] + words = vocab_words[1:] + prefix_group = [] + for word in words: + new_word = prefix + word + prefix_group.append(new_word) + + return " :: ".join(prefix_group) + + +def remove_suffix_ness(word): + """ + + :param word: str of word to remove suffix from. + :return: str of word with suffix removed & spelling adjusted. + + This function takes in a word and returns the base word with `ness` removed. + """ + + word = word.rstrip("ness") + lettres = list(word) + voyelles = ['a', 'e', 'i', 'o', 'u', 'y', 'A', 'E', 'I', '0', 'U', 'Y'] + for voyelle in voyelles: + if ((lettres[-1] == 'i') & (lettres[-2] != voyelle)): + lettres[-1] = "y" + word = "".join(lettres) + return word + + +def noun_to_verb(sentence, index): + """ + + :param sentence: str that uses the word in sentence + :param index: index of the word to remove and transform + :return: str word that changes the extracted adjective to a verb. + + A function takes a `sentence` using the + vocabulary word, and the `index` of the word once that sentence + is split apart. The function should return the extracted + adjective as a verb. + """ + + words = sentence.split() + word = words[-1].rstrip(".") + return words[index] + 'en' + From 497861e50ccad9a2d9707ca643e9cd29e3766d64 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:28 +0000 Subject: [PATCH 17/74] [Sync Iteration] python/little-sisters-vocab/4 --- .../python/little-sisters-vocab/4/strings.py | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 solutions/python/little-sisters-vocab/4/strings.py diff --git a/solutions/python/little-sisters-vocab/4/strings.py b/solutions/python/little-sisters-vocab/4/strings.py new file mode 100644 index 00000000000..1389223c4c0 --- /dev/null +++ b/solutions/python/little-sisters-vocab/4/strings.py @@ -0,0 +1,73 @@ +def add_prefix_un(word): + """ + + :param word: str of a root word + :return: str of root word with un prefix + + This function takes `word` as a parameter and + returns a new word with an 'un' prefix. + """ + + return "un" + word + + +def make_word_groups(vocab_words): + """ + + :param vocab_words: list of vocabulary words with a prefix. + :return: str of prefix followed by vocabulary words with + prefix applied, separated by ' :: '. + + This function takes a `vocab_words` list and returns a string + with the prefix and the words with prefix applied, separated + by ' :: '. + """ + if (len(vocab_words) > 3): + prefix = vocab_words[0] + words = vocab_words[1:] + prefix_group = [] + for word in words: + new_word = prefix + word + prefix_group.append(new_word) + + return " :: ".join(prefix_group) + + +def remove_suffix_ness(word): + """ + + :param word: str of word to remove suffix from. + :return: str of word with suffix removed & spelling adjusted. + + This function takes in a word and returns the base word with `ness` removed. + """ + + word = word.rstrip("ness") + lettres = list(word) + voyelles = ['a', 'e', 'i', 'o', 'u', 'y', 'A', 'E', 'I', '0', 'U', 'Y'] + for voyelle in voyelles: + if ((lettres[-1] == 'i') & (lettres[-2] != voyelle)): + lettres[-1] = "y" + word = "".join(lettres) + return word + + +def noun_to_verb(sentence, index): + """ + + :param sentence: str that uses the word in sentence + :param index: index of the word to remove and transform + :return: str word that changes the extracted adjective to a verb. + + A function takes a `sentence` using the + vocabulary word, and the `index` of the word once that sentence + is split apart. The function should return the extracted + adjective as a verb. + """ + + words = sentence.split() + word = words[index] + word.rstrip(".") + + return word + 'en' + From 559fea9e0324ce1635a650edec64bb51f537a8ce Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:29 +0000 Subject: [PATCH 18/74] [Sync Iteration] python/little-sisters-vocab/5 --- .../python/little-sisters-vocab/5/strings.py | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 solutions/python/little-sisters-vocab/5/strings.py diff --git a/solutions/python/little-sisters-vocab/5/strings.py b/solutions/python/little-sisters-vocab/5/strings.py new file mode 100644 index 00000000000..f98b0da4752 --- /dev/null +++ b/solutions/python/little-sisters-vocab/5/strings.py @@ -0,0 +1,73 @@ +def add_prefix_un(word): + """ + + :param word: str of a root word + :return: str of root word with un prefix + + This function takes `word` as a parameter and + returns a new word with an 'un' prefix. + """ + + return "un" + word + + +def make_word_groups(vocab_words): + """ + + :param vocab_words: list of vocabulary words with a prefix. + :return: str of prefix followed by vocabulary words with + prefix applied, separated by ' :: '. + + This function takes a `vocab_words` list and returns a string + with the prefix and the words with prefix applied, separated + by ' :: '. + """ + if (len(vocab_words) > 3): + prefix = vocab_words[0] + words = vocab_words[1:] + prefix_group = [] + for word in words: + new_word = prefix + word + prefix_group.append(new_word) + + return " :: ".join(prefix_group) + + +def remove_suffix_ness(word): + """ + + :param word: str of word to remove suffix from. + :return: str of word with suffix removed & spelling adjusted. + + This function takes in a word and returns the base word with `ness` removed. + """ + + word = word.rstrip("ness") + lettres = list(word) + voyelles = ['a', 'e', 'i', 'o', 'u', 'y', 'A', 'E', 'I', '0', 'U', 'Y'] + for voyelle in voyelles: + if ((lettres[-1] == 'i') & (lettres[-2] != voyelle)): + lettres[-1] = "y" + word = "".join(lettres) + return word + + +def noun_to_verb(sentence, index): + """ + + :param sentence: str that uses the word in sentence + :param index: index of the word to remove and transform + :return: str word that changes the extracted adjective to a verb. + + A function takes a `sentence` using the + vocabulary word, and the `index` of the word once that sentence + is split apart. The function should return the extracted + adjective as a verb. + """ + + words = sentence.split() + word = words[index] + word = word.rstrip(".") + + return word + 'en' + From d886cda26f643e2986d93cb42738c6a2806421d5 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:29 +0000 Subject: [PATCH 19/74] [Sync Iteration] python/little-sisters-vocab/6 --- .../python/little-sisters-vocab/6/strings.py | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 solutions/python/little-sisters-vocab/6/strings.py diff --git a/solutions/python/little-sisters-vocab/6/strings.py b/solutions/python/little-sisters-vocab/6/strings.py new file mode 100644 index 00000000000..de2bb461be5 --- /dev/null +++ b/solutions/python/little-sisters-vocab/6/strings.py @@ -0,0 +1,74 @@ +def add_prefix_un(word): + """ + + :param word: str of a root word + :return: str of root word with un prefix + + This function takes `word` as a parameter and + returns a new word with an 'un' prefix. + """ + + return "un" + word + + +def make_word_groups(vocab_words): + """ + + :param vocab_words: list of vocabulary words with a prefix. + :return: str of prefix followed by vocabulary words with + prefix applied, separated by ' :: '. + + This function takes a `vocab_words` list and returns a string + with the prefix and the words with prefix applied, separated + by ' :: '. + """ + if (len(vocab_words) > 3): + prefix = vocab_words[0] + words = vocab_words[1:] + prefix_group = [] + for word in words: + new_word = prefix + word + prefix_group.append(new_word) + + return " :: ".join(prefix_group) + + +def remove_suffix_ness(word): + """ + + :param word: str of word to remove suffix from. + :return: str of word with suffix removed & spelling adjusted. + + This function takes in a word and returns the base word with `ness` removed. + """ + + word = word.rstrip("ness") + lettres = list(word) + voyelles = ['a', 'e', 'i', 'o', 'u', 'y', 'A', 'E', 'I', '0', 'U', 'Y'] + for voyelle in voyelles: + if ((lettres[-1] == 'i') & (lettres[-2] != voyelle)): + lettres[-1] = "y" + word = "".join(lettres) + return word + + +def noun_to_verb(sentence, index): + """ + + :param sentence: str that uses the word in sentence + :param index: index of the word to remove and transform + :return: str word that changes the extracted adjective to a verb. + + A function takes a `sentence` using the + vocabulary word, and the `index` of the word once that sentence + is split apart. The function should return the extracted + adjective as a verb. + """ + + words = sentence.split() + word = words[index] + if (index == -1): + word = word.strip(".") + + return word + 'en' + From 9623271afe7f024d2fffcc5fff5f4b6e475917dd Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:30 +0000 Subject: [PATCH 20/74] [Sync Iteration] python/little-sisters-vocab/7 --- .../python/little-sisters-vocab/7/strings.py | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 solutions/python/little-sisters-vocab/7/strings.py diff --git a/solutions/python/little-sisters-vocab/7/strings.py b/solutions/python/little-sisters-vocab/7/strings.py new file mode 100644 index 00000000000..2ca4d41c2d2 --- /dev/null +++ b/solutions/python/little-sisters-vocab/7/strings.py @@ -0,0 +1,74 @@ +def add_prefix_un(word): + """ + + :param word: str of a root word + :return: str of root word with un prefix + + This function takes `word` as a parameter and + returns a new word with an 'un' prefix. + """ + + return "un" + word + + +def make_word_groups(vocab_words): + """ + + :param vocab_words: list of vocabulary words with a prefix. + :return: str of prefix followed by vocabulary words with + prefix applied, separated by ' :: '. + + This function takes a `vocab_words` list and returns a string + with the prefix and the words with prefix applied, separated + by ' :: '. + """ + + prefix = vocab_words[0] + words = vocab_words[1:] + prefix_group = [prefix] + for word in words: + new_word = prefix + word + prefix_group.append(new_word) + + result = " :: ".join(prefix_group) + return result + + +def remove_suffix_ness(word): + """ + + :param word: str of word to remove suffix from. + :return: str of word with suffix removed & spelling adjusted. + + This function takes in a word and returns the base word with `ness` removed. + """ + + word = word.rstrip("ness") + lettres = list(word) + voyelles = ['a', 'e', 'i', 'o', 'u', 'y', 'A', 'E', 'I', '0', 'U', 'Y'] + for voyelle in voyelles: + if ((lettres[-1] == 'i') & (lettres[-2] != voyelle)): + lettres[-1] = "y" + word = "".join(lettres) + return word + + +def noun_to_verb(sentence, index): + """ + + :param sentence: str that uses the word in sentence + :param index: index of the word to remove and transform + :return: str word that changes the extracted adjective to a verb. + + A function takes a `sentence` using the + vocabulary word, and the `index` of the word once that sentence + is split apart. The function should return the extracted + adjective as a verb. + """ + + words = sentence.split() + word = words[index] + if (index == -1): + word = word.strip(".") + + return word + 'en' From c4d3bc8eaa55d0ad604ac365c82d5dbaf935db7a Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:30 +0000 Subject: [PATCH 21/74] [Sync Iteration] python/little-sisters-vocab/8 --- .../python/little-sisters-vocab/8/strings.py | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 solutions/python/little-sisters-vocab/8/strings.py diff --git a/solutions/python/little-sisters-vocab/8/strings.py b/solutions/python/little-sisters-vocab/8/strings.py new file mode 100644 index 00000000000..4488483f78e --- /dev/null +++ b/solutions/python/little-sisters-vocab/8/strings.py @@ -0,0 +1,74 @@ +""" Little Sister's Vocabulary """ + +def add_prefix_un(word): + """ + + :param word: str of a root word + :return: str of root word with un prefix + + This function takes `word` as a parameter and + returns a new word with an 'un' prefix. + """ + + return "un" + word + + +def make_word_groups(vocab_words): + """ + + :param vocab_words: list of vocabulary words with a prefix. + :return: str of prefix followed by vocabulary words with + prefix applied, separated by ' :: '. + + This function takes a `vocab_words` list and returns a string + with the prefix and the words with prefix applied, separated + by ' :: '. + """ + + prefix = vocab_words[0] + words = vocab_words[1:] + prefix_group = [prefix] + for word in words: + new_word = prefix + word + prefix_group.append(new_word) + result = " :: ".join(prefix_group) + return result + + +def remove_suffix_ness(word): + """ + + :param word: str of word to remove suffix from. + :return: str of word with suffix removed & spelling adjusted. + + This function takes in a word and returns the base word with `ness` removed. + """ + + word = word.rstrip("ness") + lettres = list(word) + voyelles = ['a', 'e', 'i', 'o', 'u', 'y', 'A', 'E', 'I', '0', 'U', 'Y'] + for voyelle in voyelles: + if (lettres[-1] == 'i') & (lettres[-2] != voyelle): + lettres[-1] = "y" + word = "".join(lettres) + return word + + +def noun_to_verb(sentence, index): + """ + + :param sentence: str that uses the word in sentence + :param index: index of the word to remove and transform + :return: str word that changes the extracted adjective to a verb. + + A function takes a `sentence` using the + vocabulary word, and the `index` of the word once that sentence + is split apart. The function should return the extracted + adjective as a verb. + """ + + words = sentence.split() + word = words[index] + if index == -1: + word = word.strip(".") + return word + 'en' From 9191a6750c792384435d6e4e457f47ce921d6db5 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:31 +0000 Subject: [PATCH 22/74] [Sync Iteration] python/meltdown-mitigation/1 --- .../meltdown-mitigation/1/conditionals.py | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 solutions/python/meltdown-mitigation/1/conditionals.py diff --git a/solutions/python/meltdown-mitigation/1/conditionals.py b/solutions/python/meltdown-mitigation/1/conditionals.py new file mode 100644 index 00000000000..070ac11b90a --- /dev/null +++ b/solutions/python/meltdown-mitigation/1/conditionals.py @@ -0,0 +1,80 @@ +""" Meltdown Mitigation exercise """ + + +def is_criticality_balanced(temperature, neutrons_emitted): + """Verify criticality is balanced. + + :param temperature: temperature value (integer or float) + :param neutrons_emitted: number of neutrons emitted per second (integer or float) + :return: boolean True if conditions met, False if not + + A reactor is said to be critical if it satisfies the following conditions: + - The temperature is less than 800. + - The number of neutrons emitted per second is greater than 500. + - The product of temperature and neutrons emitted per second is less than 500000. + """ + + if (temperature < 800 ) & (neutrons_emitted > 500) & ((temperature * neutrons_emitted) < 500000): + return True + else: + return False + + + +def reactor_efficiency(voltage, current, theoretical_max_power): + """Assess reactor efficiency zone. + + :param voltage: voltage value (integer or float) + :param current: current value (integer or float) + :param theoretical_max_power: power that corresponds to a 100% efficiency (integer or float) + :return: str one of 'green', 'orange', 'red', or 'black' + + Efficiency can be grouped into 4 bands: + + 1. green -> efficiency of 80% or more, + 2. orange -> efficiency of less than 80% but at least 60%, + 3. red -> efficiency below 60%, but still 30% or more, + 4. black -> less than 30% efficient. + + The percentage value is calculated as + (generated power/ theoretical max power)*100 + where generated power = voltage * current + """ + + generated_power= voltage* current + percent = (generated_power/theoretical_max_power)*100 + if (percent <= 100 ) & (percent >= 80): + return "green" + elif (percent < 80 ) & (percent >= 60): + return "orange" + elif (percent < 60 ) & (percent >= 30): + return "red" + elif (percent < 30) & (percent >= 0): + return "black" + else: + return str(percent) + +def fail_safe(temperature, neutrons_produced_per_second, threshold): + """Assess and return status code for the reactor. + + :param temperature: value of the temperature (integer or float) + :param neutrons_produced_per_second: neutron flux (integer or float) + :param threshold: threshold (integer or float) + :return: str one of: 'LOW', 'NORMAL', 'DANGER' + + - `temperature * neutrons per second` < 90% of `threshold` == 'LOW' + - `temperature * neutrons per second` +/- 10% of `threshold` == 'NORMAL' + - `temperature * neutrons per second` is not in the above-stated ranges == 'DANGER' + """ + + temp_neutrons = (temperature * neutrons_produced_per_second) + percent_threshold = (threshold * 0.9) + print(temp_neutrons) + print(percent_threshold) + if temp_neutrons < percent_threshold: + return "LOW" + elif temp_neutrons >= percent_threshold: + return "NORMAL" + else: + return "DANGER" + From 36c9309120d1f25c74ebadbff1926e2d20c62516 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:31 +0000 Subject: [PATCH 23/74] [Sync Iteration] python/meltdown-mitigation/2 --- .../meltdown-mitigation/2/conditionals.py | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 solutions/python/meltdown-mitigation/2/conditionals.py diff --git a/solutions/python/meltdown-mitigation/2/conditionals.py b/solutions/python/meltdown-mitigation/2/conditionals.py new file mode 100644 index 00000000000..c15b54380fa --- /dev/null +++ b/solutions/python/meltdown-mitigation/2/conditionals.py @@ -0,0 +1,77 @@ +""" Meltdown Mitigation exercise """ + + +def is_criticality_balanced(temperature, neutrons_emitted): + """Verify criticality is balanced. + + :param temperature: temperature value (integer or float) + :param neutrons_emitted: number of neutrons emitted per second (integer or float) + :return: boolean True if conditions met, False if not + + A reactor is said to be critical if it satisfies the following conditions: + - The temperature is less than 800. + - The number of neutrons emitted per second is greater than 500. + - The product of temperature and neutrons emitted per second is less than 500000. + """ + + if (temperature < 800 ) & (neutrons_emitted > 500) & ((temperature * neutrons_emitted) < 500000): + return True + else: + return False + + + +def reactor_efficiency(voltage, current, theoretical_max_power): + """Assess reactor efficiency zone. + + :param voltage: voltage value (integer or float) + :param current: current value (integer or float) + :param theoretical_max_power: power that corresponds to a 100% efficiency (integer or float) + :return: str one of 'green', 'orange', 'red', or 'black' + + Efficiency can be grouped into 4 bands: + + 1. green -> efficiency of 80% or more, + 2. orange -> efficiency of less than 80% but at least 60%, + 3. red -> efficiency below 60%, but still 30% or more, + 4. black -> less than 30% efficient. + + The percentage value is calculated as + (generated power/ theoretical max power)*100 + where generated power = voltage * current + """ + + generated_power= voltage* current + percent = (generated_power/theoretical_max_power)*100 + if (percent <= 100 ) & (percent >= 80): + return "green" + elif (percent < 80 ) & (percent >= 60): + return "orange" + elif (percent < 60 ) & (percent >= 30): + return "red" + elif (percent < 30) & (percent >= 0): + return "black" + else: + return str(percent) + +def fail_safe(temperature, neutrons_produced_per_second, threshold): + """Assess and return status code for the reactor. + + :param temperature: value of the temperature (integer or float) + :param neutrons_produced_per_second: neutron flux (integer or float) + :param threshold: threshold (integer or float) + :return: str one of: 'LOW', 'NORMAL', 'DANGER' + + - `temperature * neutrons per second` < 90% of `threshold` == 'LOW' + - `temperature * neutrons per second` +/- 10% of `threshold` == 'NORMAL' + - `temperature * neutrons per second` is not in the above-stated ranges == 'DANGER' + """ + + criticality = temperature * neutrons_produced_per_second + if criticality < (threshold * 0.9): + return "LOW" + if (threshold * 0.9) <= criticality <= (threshold * 1.1) : + return "NORMAL" + + return "DANGER" + From 28db9e979113f0a9046b8b157319e33890b56fcd Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:32 +0000 Subject: [PATCH 24/74] [Sync Iteration] python/tisbury-treasure-hunt/1 --- .../python/tisbury-treasure-hunt/1/tuples.py | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 solutions/python/tisbury-treasure-hunt/1/tuples.py diff --git a/solutions/python/tisbury-treasure-hunt/1/tuples.py b/solutions/python/tisbury-treasure-hunt/1/tuples.py new file mode 100644 index 00000000000..687b839e8d7 --- /dev/null +++ b/solutions/python/tisbury-treasure-hunt/1/tuples.py @@ -0,0 +1,60 @@ +def get_coordinate(record): + """ + + :param record: tuple - a (treasure, coordinate) pair. + :return: str - the extracted map coordinate. + """ + + return record[1] + + +def convert_coordinate(coordinate): + """ + + :param coordinate: str - a string map coordinate + :return: tuple - the string coordinate seperated into its individual components. + """ + + lettre = list(coordinate) + return tuple(lettre) + + +def compare_records(azara_record, rui_record): + """ + + :param azara_record: tuple - a (treasure, coordinate) pair. + :param rui_record: tuple - a (location, coordinate, quadrant) trio. + :return: bool - True if coordinates match, False otherwise. + """ + + word_coordinate = ''.join(rui_record[1]) + return azara_record[1] == word_coordinate + + +def create_record(azara_record, rui_record): + """ + + :param azara_record: tuple - a (treasure, coordinate) pair. + :param rui_record: tuple - a (location, coordinate, quadrant) trio. + :return: tuple - combined record, or "not a match" if the records are incompatible. + """ + + if compare_records(azara_record, rui_record) == True : + return azara_record + rui_record + return "not a match" + + + + + +def clean_up(combined_record_group): + """ + + :param combined_record_group: tuple of tuples - everything from both participants. + :return: string of tuples separated by newlines - everything "cleaned". Excess coordinates and information removed. + """ + + words = "" + for combined_record in combined_record_group: + words += f"{(combined_record[0], combined_record[2], combined_record[3], combined_record[4])}\n" + return words From 44d6e1165b33197a985083f7785d54a1c3c002e4 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:32 +0000 Subject: [PATCH 25/74] [Sync Iteration] python/tisbury-treasure-hunt/2 --- .../python/tisbury-treasure-hunt/2/tuples.py | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 solutions/python/tisbury-treasure-hunt/2/tuples.py diff --git a/solutions/python/tisbury-treasure-hunt/2/tuples.py b/solutions/python/tisbury-treasure-hunt/2/tuples.py new file mode 100644 index 00000000000..d757e4794aa --- /dev/null +++ b/solutions/python/tisbury-treasure-hunt/2/tuples.py @@ -0,0 +1,58 @@ +""" Tisbury Treasure Hunt """ +def get_coordinate(record): + """ + + :param record: tuple - a (treasure, coordinate) pair. + :return: str - the extracted map coordinate. + """ + + return record[1] + + +def convert_coordinate(coordinate): + """ + + :param coordinate: str - a string map coordinate + :return: tuple - the string coordinate seperated into its individual components. + """ + + lettre = list(coordinate) + return tuple(lettre) + + +def compare_records(azara_record, rui_record): + """ + + :param azara_record: tuple - a (treasure, coordinate) pair. + :param rui_record: tuple - a (location, coordinate, quadrant) trio. + :return: bool - True if coordinates match, False otherwise. + """ + + word_coordinate = ''.join(rui_record[1]) + return azara_record[1] == word_coordinate + + +def create_record(azara_record, rui_record): + """ + + :param azara_record: tuple - a (treasure, coordinate) pair. + :param rui_record: tuple - a (location, coordinate, quadrant) trio. + :return: tuple - combined record, or "not a match" if the records are incompatible. + """ + + if compare_records(azara_record, rui_record) == True : + return azara_record + rui_record + return "not a match" + + +def clean_up(combined_record_group): + """ + + :param combined_record_group: tuple of tuples - everything from both participants. + :return: string of tuples separated by newlines - everything "cleaned". Excess coordinates and information removed. + """ + + words = "" + for combined_record in combined_record_group: + words += f"{(combined_record[0], combined_record[2], combined_record[3], combined_record[4])}\n" + return words From 16711a05a75bf1efd5c7ff5969014067880ee8b1 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:33 +0000 Subject: [PATCH 26/74] [Sync Iteration] python/tisbury-treasure-hunt/3 --- .../python/tisbury-treasure-hunt/3/tuples.py | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 solutions/python/tisbury-treasure-hunt/3/tuples.py diff --git a/solutions/python/tisbury-treasure-hunt/3/tuples.py b/solutions/python/tisbury-treasure-hunt/3/tuples.py new file mode 100644 index 00000000000..6a9c2d3c002 --- /dev/null +++ b/solutions/python/tisbury-treasure-hunt/3/tuples.py @@ -0,0 +1,58 @@ +""" Tisbury Treasure Hunt """ +def get_coordinate(record): + """ + + :param record: tuple - a (treasure, coordinate) pair. + :return: str - the extracted map coordinate. + """ + + return record[1] + + +def convert_coordinate(coordinate): + """ + + :param coordinate: str - a string map coordinate + :return: tuple - the string coordinate seperated into its individual components. + """ + + lettre = list(coordinate) + return tuple(lettre) + + +def compare_records(azara_record, rui_record): + """ + + :param azara_record: tuple - a (treasure, coordinate) pair. + :param rui_record: tuple - a (location, coordinate, quadrant) trio. + :return: bool - True if coordinates match, False otherwise. + """ + + word_coordinate = ''.join(rui_record[1]) + return azara_record[1] == word_coordinate + + +def create_record(azara_record, rui_record): + """ + + :param azara_record: tuple - a (treasure, coordinate) pair. + :param rui_record: tuple - a (location, coordinate, quadrant) trio. + :return: tuple - combined record, or "not a match" if the records are incompatible. + """ + + if compare_records(azara_record, rui_record) is True : + return azara_record + rui_record + return "not a match" + + +def clean_up(combined_record_group): + """ + + :param combined_record_group: tuple of tuples - everything from both participants. + :return: string of tuples separated by newlines - everything "cleaned". Excess coordinates and information removed. + """ + + words = "" + for combined_record in combined_record_group: + words += f"{(combined_record[0], combined_record[2], combined_record[3], combined_record[4])}\n" + return words From b024f424d344621a65673d2f32fc9444b5d2c2ef Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:33 +0000 Subject: [PATCH 27/74] [Sync Iteration] python/tisbury-treasure-hunt/4 --- .../python/tisbury-treasure-hunt/4/tuples.py | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 solutions/python/tisbury-treasure-hunt/4/tuples.py diff --git a/solutions/python/tisbury-treasure-hunt/4/tuples.py b/solutions/python/tisbury-treasure-hunt/4/tuples.py new file mode 100644 index 00000000000..dd5f110ee49 --- /dev/null +++ b/solutions/python/tisbury-treasure-hunt/4/tuples.py @@ -0,0 +1,58 @@ +""" Tisbury Treasure Hunt """ +def get_coordinate(record): + """ + + :param record: tuple - a (treasure, coordinate) pair. + :return: str - the extracted map coordinate. + """ + + return record[1] + + +def convert_coordinate(coordinate): + """ + + :param coordinate: str - a string map coordinate + :return: tuple - the string coordinate seperated into its individual components. + """ + + lettre = list(coordinate) + return tuple(lettre) + + +def compare_records(azara_record, rui_record): + """ + + :param azara_record: tuple - a (treasure, coordinate) pair. + :param rui_record: tuple - a (location, coordinate, quadrant) trio. + :return: bool - True if coordinates match, False otherwise. + """ + + word_coordinate = ''.join(rui_record[1]) + return azara_record[1] == word_coordinate + + +def create_record(azara_record, rui_record): + """ + + :param azara_record: tuple - a (treasure, coordinate) pair. + :param rui_record: tuple - a (location, coordinate, quadrant) trio. + :return: tuple - combined record, or "not a match" if the records are incompatible. + """ + + if compare_records(azara_record, rui_record) is True : + return azara_record + rui_record + return "not a match" + + +def clean_up(combined_record_group): + """ + + :param combined_record_group: tuple of tuples - everything from both participants. + :return: string of tuples separated by newlines - everything "cleaned". Excess coordinates and information removed. + """ + + words = "" + for combined_record in combined_record_group: + words += f"{(combined_record[0], combined_record[2], combined_record[3], combined_record[4])}\n" + return words From c41d7938e2ea0eb35283e6f35b30372dac6f6893 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:34 +0000 Subject: [PATCH 28/74] [Sync Iteration] python/tisbury-treasure-hunt/5 --- .../python/tisbury-treasure-hunt/5/tuples.py | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 solutions/python/tisbury-treasure-hunt/5/tuples.py diff --git a/solutions/python/tisbury-treasure-hunt/5/tuples.py b/solutions/python/tisbury-treasure-hunt/5/tuples.py new file mode 100644 index 00000000000..de015b21d98 --- /dev/null +++ b/solutions/python/tisbury-treasure-hunt/5/tuples.py @@ -0,0 +1,58 @@ +""" Tisbury Treasure Hunt """ +def get_coordinate(record): + """ + + :param record: tuple - a (treasure, coordinate) pair. + :return: str - the extracted map coordinate. + """ + + return record[1] + + +def convert_coordinate(coordinate): + """ + + :param coordinate: str - a string map coordinate + :return: tuple - the string coordinate seperated into its individual components. + """ + + lettre = list(coordinate) + return tuple(lettre) + + +def compare_records(azara_record, rui_record): + """ + + :param azara_record: tuple - a (treasure, coordinate) pair. + :param rui_record: tuple - a (location, coordinate, quadrant) trio. + :return: bool - True if coordinates match, False otherwise. + """ + + word_coordinate = ''.join(rui_record[1]) + return azara_record[1] == word_coordinate + + +def create_record(azara_record, rui_record): + """ + + :param azara_record: tuple - a (treasure, coordinate) pair. + :param rui_record: tuple - a (location, coordinate, quadrant) trio. + :return: tuple - combined record, or "not a match" if the records are incompatible. + """ + + if compare_records(azara_record, rui_record) is True : + return azara_record + rui_record + return "not a match" + + +def clean_up(combined_record_group): + """ + + :param combined_record_group: tuple of tuples - everything from both participants. + :return: string of tuples separated by newlines - everything "cleaned". Excess coordinates and information removed. + """ + + words = "" + for combined_record in combined_record_group: + words += f"{(combined_record[0], combined_record[2], combined_record[3], combined_record[4])}\n" + return words From 9f4e269b67bdce5b9e70468f73ba2bad2f412b30 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:34 +0000 Subject: [PATCH 29/74] [Sync Iteration] python/guidos-gorgeous-lasagna/1 --- .../guidos-gorgeous-lasagna/1/lasagna.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 solutions/python/guidos-gorgeous-lasagna/1/lasagna.py diff --git a/solutions/python/guidos-gorgeous-lasagna/1/lasagna.py b/solutions/python/guidos-gorgeous-lasagna/1/lasagna.py new file mode 100644 index 00000000000..8cf321e0a5e --- /dev/null +++ b/solutions/python/guidos-gorgeous-lasagna/1/lasagna.py @@ -0,0 +1,22 @@ +# TODO: define the 'EXPECTED_BAKE_TIME' constant +EXPECTED_BAKE_TIME = 40 + +def bake_time_remaining(time_actual): + return EXPECTED_BAKE_TIME - time_actual + +# TODO: define the 'preparation_time_in_minutes()' function +# and consider using 'PREPARATION_TIME' here + +def preparation_time_in_minutes(number_of_layers): + return number_of_layers * 2 + +# TODO: define the 'elapsed_time_in_minutes()' function + +def elapsed_time_in_minutes(number_of_layers, elapsed_bake_time): + """ + Return elapsed cooking time. + + This function takes two numbers representing the number of layers & the time already spent + baking and calculates the total elapsed minutes spent cooking the lasagna. + """ + return preparation_time_in_minutes(number_of_layers) + elapsed_bake_time \ No newline at end of file From d09f71810ebc38cd86383139c0752e295e7b4d5c Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:34 +0000 Subject: [PATCH 30/74] [Sync Iteration] python/guidos-gorgeous-lasagna/2 --- .../guidos-gorgeous-lasagna/2/lasagna.py | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 solutions/python/guidos-gorgeous-lasagna/2/lasagna.py diff --git a/solutions/python/guidos-gorgeous-lasagna/2/lasagna.py b/solutions/python/guidos-gorgeous-lasagna/2/lasagna.py new file mode 100644 index 00000000000..182001bb9b9 --- /dev/null +++ b/solutions/python/guidos-gorgeous-lasagna/2/lasagna.py @@ -0,0 +1,31 @@ +# TODO: define the 'EXPECTED_BAKE_TIME' constant +EXPECTED_BAKE_TIME = 40 + +def bake_time_remaining(time_actual): + """Calculez le temps de cuisson restant. + + :param elapsed_bake_time : temps de cuisson entier déjà écoulé. + :return : int temps de cuisson restant dérivé de 'EXPECTED_BAKE_TIME'. + + Fonction qui prend les minutes réelles de lasagne dans le quatre comme + un argument et ajouter combien de minutes la lasagne a encore besoin de cuire + basé sur le `EXPECTED_BAKE_TIME`. + """ + return EXPECTED_BAKE_TIME - time_actual + +# TODO: define the 'preparation_time_in_minutes()' function +# and consider using 'PREPARATION_TIME' here + +def preparation_time_in_minutes(number_of_layers): + return number_of_layers * 2 + +# TODO: define the 'elapsed_time_in_minutes()' function + +def elapsed_time_in_minutes(number_of_layers, elapsed_bake_time): + """ + Return elapsed cooking time. + + This function takes two numbers representing the number of layers & the time already spent + baking and calculates the total elapsed minutes spent cooking the lasagna. + """ + return preparation_time_in_minutes(number_of_layers) + elapsed_bake_time \ No newline at end of file From 65a10465b108920d71b581f7c1a5cc56a31f8f04 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:35 +0000 Subject: [PATCH 31/74] [Sync Iteration] python/guidos-gorgeous-lasagna/3 --- .../guidos-gorgeous-lasagna/3/lasagna.py | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 solutions/python/guidos-gorgeous-lasagna/3/lasagna.py diff --git a/solutions/python/guidos-gorgeous-lasagna/3/lasagna.py b/solutions/python/guidos-gorgeous-lasagna/3/lasagna.py new file mode 100644 index 00000000000..d8ba02ce0e8 --- /dev/null +++ b/solutions/python/guidos-gorgeous-lasagna/3/lasagna.py @@ -0,0 +1,31 @@ +# TODO: define the 'EXPECTED_BAKE_TIME' constant +EXPECTED_BAKE_TIME = 40 + +def bake_time_remaining(elapsed_bake_time): + """Calculate the remaining cooking time. + + :param elapsed_bake_time: entire baking time already elapsed. + :return: int remaining cooking time derived from 'EXPECTED_BAKE_TIME'. + + Function that takes the actual lasagna minutes in the four like + an argument and add how many minutes the lasagna still needs to cook + based on the `EXPECTED_BAKE_TIME`. + """ + return EXPECTED_BAKE_TIME - elapsed_bake_time + +# TODO: define the 'preparation_time_in_minutes()' function +# and consider using 'PREPARATION_TIME' here + +def preparation_time_in_minutes(number_of_layers): + return number_of_layers * 2 + +# TODO: define the 'elapsed_time_in_minutes()' function + +def elapsed_time_in_minutes(number_of_layers, elapsed_bake_time): + """ + Return elapsed cooking time. + + This function takes two numbers representing the number of layers & the time already spent + baking and calculates the total elapsed minutes spent cooking the lasagna. + """ + return preparation_time_in_minutes(number_of_layers) + elapsed_bake_time \ No newline at end of file From d5bcf97d52c4d98af209edec5296e33baf3b0443 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:35 +0000 Subject: [PATCH 32/74] [Sync Iteration] python/guidos-gorgeous-lasagna/4 --- .../guidos-gorgeous-lasagna/4/lasagna.py | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 solutions/python/guidos-gorgeous-lasagna/4/lasagna.py diff --git a/solutions/python/guidos-gorgeous-lasagna/4/lasagna.py b/solutions/python/guidos-gorgeous-lasagna/4/lasagna.py new file mode 100644 index 00000000000..646c14d597c --- /dev/null +++ b/solutions/python/guidos-gorgeous-lasagna/4/lasagna.py @@ -0,0 +1,40 @@ +# TODO: define the 'EXPECTED_BAKE_TIME' constant +EXPECTED_BAKE_TIME = 40 + +def bake_time_remaining(elapsed_bake_time): + """Calculate the remaining cooking time. + + :param elapsed_bake_time: entire baking time already elapsed. + :return: int - remaining cooking time derived from 'EXPECTED_BAKE_TIME'. + + Function that takes the actual lasagna minutes in the four like + an argument and add how many minutes the lasagna still needs to cook + based on the `EXPECTED_BAKE_TIME`. + """ + return EXPECTED_BAKE_TIME - elapsed_bake_time + +# TODO: define the 'preparation_time_in_minutes()' function +# and consider using 'PREPARATION_TIME' here + +def preparation_time_in_minutes(number_of_layers): + """Calculate the preparation time in minutes. + + :param number_of_layers: nombre de couches de la lasagne. + :return: int - temps de preparation de la lasagne. + + Le nombre de minutes pour la préparation de lasagne + """ + return number_of_layers * 2 + +# TODO: define the 'elapsed_time_in_minutes()' function + +def elapsed_time_in_minutes(number_of_layers, elapsed_bake_time): + """Calculez le temps de cuisson total écoulé. + + :param number_of_layers: nombre de couches de la lasagne. + :param elapsed_bake_time: entire baking time already elapsed. + :return: int - nombre total de minutes de cuisson + + Take the preparation time in minutes and add it to elapsed_bake_time, returning the result + """ + return preparation_time_in_minutes(number_of_layers) + elapsed_bake_time \ No newline at end of file From 427158c7680f3441a4208157e8170c65f14a5823 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:36 +0000 Subject: [PATCH 33/74] [Sync Iteration] python/guidos-gorgeous-lasagna/5 --- .../guidos-gorgeous-lasagna/5/lasagna.py | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 solutions/python/guidos-gorgeous-lasagna/5/lasagna.py diff --git a/solutions/python/guidos-gorgeous-lasagna/5/lasagna.py b/solutions/python/guidos-gorgeous-lasagna/5/lasagna.py new file mode 100644 index 00000000000..0943b730174 --- /dev/null +++ b/solutions/python/guidos-gorgeous-lasagna/5/lasagna.py @@ -0,0 +1,41 @@ +# TODO: define the 'EXPECTED_BAKE_TIME' constant +EXPECTED_BAKE_TIME = 40 +PREPARATION_TIME = 2 + +def bake_time_remaining(elapsed_bake_time): + """Calculate the remaining cooking time. + + :param elapsed_bake_time: entire baking time already elapsed. + :return: int - remaining cooking time derived from 'EXPECTED_BAKE_TIME'. + + Function that takes the actual lasagna minutes in the four like + an argument and add how many minutes the lasagna still needs to cook + based on the `EXPECTED_BAKE_TIME`. + """ + return EXPECTED_BAKE_TIME - elapsed_bake_time + +# TODO: define the 'preparation_time_in_minutes()' function +# and consider using 'PREPARATION_TIME' here + +def preparation_time_in_minutes(number_of_layers): + """Calculate the preparation time in minutes. + + :param number_of_layers: nombre de couches de la lasagne. + :return: int - temps de preparation de la lasagne. + + Le nombre de minutes pour la préparation de lasagne + """ + return number_of_layers * PREPARATION_TIME + +# TODO: define the 'elapsed_time_in_minutes()' function + +def elapsed_time_in_minutes(number_of_layers, elapsed_bake_time): + """Calculez le temps de cuisson total écoulé. + + :param number_of_layers: nombre de couches de la lasagne. + :param elapsed_bake_time: entire baking time already elapsed. + :return: int - nombre total de minutes de cuisson + + Take the preparation time in minutes and add it to elapsed_bake_time, returning the result + """ + return preparation_time_in_minutes(number_of_layers) + elapsed_bake_time \ No newline at end of file From 87369a94755ae8ef23ecddd6640fe1596f9d4e67 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:36 +0000 Subject: [PATCH 34/74] [Sync Iteration] python/guidos-gorgeous-lasagna/6 --- .../guidos-gorgeous-lasagna/6/lasagna.py | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 solutions/python/guidos-gorgeous-lasagna/6/lasagna.py diff --git a/solutions/python/guidos-gorgeous-lasagna/6/lasagna.py b/solutions/python/guidos-gorgeous-lasagna/6/lasagna.py new file mode 100644 index 00000000000..920fd4c7ecc --- /dev/null +++ b/solutions/python/guidos-gorgeous-lasagna/6/lasagna.py @@ -0,0 +1,44 @@ +""" Guido's Gorgeous Lasagna """ + +# define the 'EXPECTED_BAKE_TIME' constant +EXPECTED_BAKE_TIME = 40 +PREPARATION_TIME = 2 + +def bake_time_remaining(elapsed_bake_time): + """Calculate the remaining cooking time. + + :param elapsed_bake_time: entire baking time already elapsed. + :return: int - remaining cooking time derived from 'EXPECTED_BAKE_TIME'. + + Function that takes the actual lasagna minutes in the four like + an argument and add how many minutes the lasagna still needs to cook + based on the `EXPECTED_BAKE_TIME`. + """ + return EXPECTED_BAKE_TIME - elapsed_bake_time + +# define the 'preparation_time_in_minutes()' function +# and consider using 'PREPARATION_TIME' here + +def preparation_time_in_minutes(number_of_layers): + """Calculate the preparation time in minutes. + + :param number_of_layers: nombre de couches de la lasagne. + :return: int - temps de preparation de la lasagne. + + Le nombre de minutes pour la préparation de lasagne + """ + return number_of_layers * PREPARATION_TIME + +# define the 'elapsed_time_in_minutes()' function + +def elapsed_time_in_minutes(number_of_layers, elapsed_bake_time): + """Calculez le temps de cuisson total écoulé. + + :param number_of_layers: nombre de couches de la lasagne. + :param elapsed_bake_time: entire baking time already elapsed. + :return: int - nombre total de minutes de cuisson + + Take the preparation time in minutes and add it to elapsed_bake_time, returning the result + """ + return preparation_time_in_minutes(number_of_layers) + elapsed_bake_time + From ca5544565082404d858eda6e653f0a1fe00011a2 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:37 +0000 Subject: [PATCH 35/74] [Sync Iteration] python/guidos-gorgeous-lasagna/7 --- .../guidos-gorgeous-lasagna/7/lasagna.py | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 solutions/python/guidos-gorgeous-lasagna/7/lasagna.py diff --git a/solutions/python/guidos-gorgeous-lasagna/7/lasagna.py b/solutions/python/guidos-gorgeous-lasagna/7/lasagna.py new file mode 100644 index 00000000000..864b1ffee17 --- /dev/null +++ b/solutions/python/guidos-gorgeous-lasagna/7/lasagna.py @@ -0,0 +1,43 @@ +""" Guido's Gorgeous Lasagna """ + +# define the 'EXPECTED_BAKE_TIME' constant +EXPECTED_BAKE_TIME = 40 +PREPARATION_TIME = 2 + +def bake_time_remaining(elapsed_bake_time): + """Calculate the remaining cooking time. + + :param elapsed_bake_time: entire baking time already elapsed. + :return: int - remaining cooking time derived from 'EXPECTED_BAKE_TIME'. + + Function that takes the actual lasagna minutes in the four like + an argument and add how many minutes the lasagna still needs to cook + based on the `EXPECTED_BAKE_TIME`. + """ + return EXPECTED_BAKE_TIME - elapsed_bake_time + +# define the 'preparation_time_in_minutes()' function +# and consider using 'PREPARATION_TIME' here + +def preparation_time_in_minutes(number_of_layers): + """Calculate the preparation time in minutes. + + :param number_of_layers: nombre de couches de la lasagne. + :return: int - temps de preparation de la lasagne. + + Le nombre de minutes pour la préparation de lasagne + """ + return number_of_layers * PREPARATION_TIME + +# define the 'elapsed_time_in_minutes()' function + +def elapsed_time_in_minutes(number_of_layers, elapsed_bake_time): + """Calculez le temps de cuisson total écoulé. + + :param number_of_layers: nombre de couches de la lasagne. + :param elapsed_bake_time: entire baking time already elapsed. + :return: int - nombre total de minutes de cuisson + + Take the preparation time in minutes and add it to elapsed_bake_time, returning the result + """ + return preparation_time_in_minutes(number_of_layers) + elapsed_bake_time From 60c8d2c470afef647d6b396add1c4a585d115221 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:37 +0000 Subject: [PATCH 36/74] [Sync Iteration] python/ghost-gobble-arcade-game/1 --- .../ghost-gobble-arcade-game/1/arcade_game.py | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 solutions/python/ghost-gobble-arcade-game/1/arcade_game.py diff --git a/solutions/python/ghost-gobble-arcade-game/1/arcade_game.py b/solutions/python/ghost-gobble-arcade-game/1/arcade_game.py new file mode 100644 index 00000000000..73bfd169171 --- /dev/null +++ b/solutions/python/ghost-gobble-arcade-game/1/arcade_game.py @@ -0,0 +1,51 @@ +def eat_ghost(power_pellet_active, touching_ghost): + """ + + :param power_pellet_active: bool - does the player have an active power pellet? + :param touching_ghost: bool - is the player touching a ghost? + :return: bool + """ + if ((power_pellet_active == True) & (touching_ghost == True)): + return True + else: + return False + + +def score(touching_power_pellet, touching_dot): + """ + + :param touching_power_pellet: bool - does the player have an active power pellet? + :param touching_dot: bool - is the player touching a dot? + :return: bool + """ + if ((touching_power_pellet == True) | (touching_dot == True)): + return True + else: + return False + + +def lose(power_pellet_active, touching_ghost): + """ + + :param power_pellet_active: bool - does the player have an active power pellet? + :param touching_ghost: bool - is the player touching a ghost? + :return: bool + """ + if ((power_pellet_active == False) & (touching_ghost == True)): + return True + else: + return False + + +def win(has_eaten_all_dots, power_pellet_active, touching_ghost): + """ + + :param has_eaten_all_dots: bool - has the player "eaten" all the dots? + :param power_pellet_active: bool - does the player have an active power pellet? + :param touching_ghost: bool - is the player touching a ghost? + :return: bool + """ + if ((has_eaten_all_dots == False) & (lose(power_pellet_active, touching_ghost) == True)): + return True + else: + return False From 14e8f63b4df203c57e5a5358862b2521e4dfb695 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:37 +0000 Subject: [PATCH 37/74] [Sync Iteration] python/ghost-gobble-arcade-game/2 --- .../ghost-gobble-arcade-game/2/arcade_game.py | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 solutions/python/ghost-gobble-arcade-game/2/arcade_game.py diff --git a/solutions/python/ghost-gobble-arcade-game/2/arcade_game.py b/solutions/python/ghost-gobble-arcade-game/2/arcade_game.py new file mode 100644 index 00000000000..a42a1c53eaa --- /dev/null +++ b/solutions/python/ghost-gobble-arcade-game/2/arcade_game.py @@ -0,0 +1,51 @@ +def eat_ghost(power_pellet_active, touching_ghost): + """ + + :param power_pellet_active: bool - does the player have an active power pellet? + :param touching_ghost: bool - is the player touching a ghost? + :return: bool + """ + if ((power_pellet_active == True) & (touching_ghost == True)): + return True + else: + return False + + +def score(touching_power_pellet, touching_dot): + """ + + :param touching_power_pellet: bool - does the player have an active power pellet? + :param touching_dot: bool - is the player touching a dot? + :return: bool + """ + if ((touching_power_pellet == True) | (touching_dot == True)): + return True + else: + return False + + +def lose(power_pellet_active, touching_ghost): + """ + + :param power_pellet_active: bool - does the player have an active power pellet? + :param touching_ghost: bool - is the player touching a ghost? + :return: bool + """ + if ((power_pellet_active == False) & (touching_ghost == True)): + return True + else: + return False + + +def win(has_eaten_all_dots, power_pellet_active, touching_ghost): + """ + + :param has_eaten_all_dots: bool - has the player "eaten" all the dots? + :param power_pellet_active: bool - does the player have an active power pellet? + :param touching_ghost: bool - is the player touching a ghost? + :return: bool + """ + if ((has_eaten_all_dots == True) & (lose(power_pellet_active, touching_ghost) != True)): + return True + else: + return False From 0e66f0658fbffea4dff5681d53e82895e6e76334 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:38 +0000 Subject: [PATCH 38/74] [Sync Iteration] python/ghost-gobble-arcade-game/3 --- .../ghost-gobble-arcade-game/3/arcade_game.py | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 solutions/python/ghost-gobble-arcade-game/3/arcade_game.py diff --git a/solutions/python/ghost-gobble-arcade-game/3/arcade_game.py b/solutions/python/ghost-gobble-arcade-game/3/arcade_game.py new file mode 100644 index 00000000000..5fdffa3d70a --- /dev/null +++ b/solutions/python/ghost-gobble-arcade-game/3/arcade_game.py @@ -0,0 +1,48 @@ +def eat_ghost(power_pellet_active, touching_ghost): + """ + + :param power_pellet_active: bool - does the player have an active power pellet? + :param touching_ghost: bool - is the player touching a ghost? + :return: bool + """ + return (power_pellet_active is True) & (touching_ghost is True) + + +def score(touching_power_pellet, touching_dot): + """ + + :param touching_power_pellet: bool - does the player have an active power pellet? + :param touching_dot: bool - is the player touching a dot? + :return: bool + """ + if ((touching_power_pellet == True) | (touching_dot == True)): + return True + else: + return False + + +def lose(power_pellet_active, touching_ghost): + """ + + :param power_pellet_active: bool - does the player have an active power pellet? + :param touching_ghost: bool - is the player touching a ghost? + :return: bool + """ + if ((power_pellet_active == False) & (touching_ghost == True)): + return True + else: + return False + + +def win(has_eaten_all_dots, power_pellet_active, touching_ghost): + """ + + :param has_eaten_all_dots: bool - has the player "eaten" all the dots? + :param power_pellet_active: bool - does the player have an active power pellet? + :param touching_ghost: bool - is the player touching a ghost? + :return: bool + """ + if ((has_eaten_all_dots == True) & (lose(power_pellet_active, touching_ghost) != True)): + return True + else: + return False From 7cdd5c22b60a333b38c5267d26fed6e27f0705cf Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:38 +0000 Subject: [PATCH 39/74] [Sync Iteration] python/ghost-gobble-arcade-game/4 --- .../ghost-gobble-arcade-game/4/arcade_game.py | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 solutions/python/ghost-gobble-arcade-game/4/arcade_game.py diff --git a/solutions/python/ghost-gobble-arcade-game/4/arcade_game.py b/solutions/python/ghost-gobble-arcade-game/4/arcade_game.py new file mode 100644 index 00000000000..b3770194b57 --- /dev/null +++ b/solutions/python/ghost-gobble-arcade-game/4/arcade_game.py @@ -0,0 +1,39 @@ +def eat_ghost(power_pellet_active, touching_ghost): + """ + + :param power_pellet_active: bool - does the player have an active power pellet? + :param touching_ghost: bool - is the player touching a ghost? + :return: bool + """ + return (power_pellet_active is True) & (touching_ghost is True) + + +def score(touching_power_pellet, touching_dot): + """ + + :param touching_power_pellet: bool - does the player have an active power pellet? + :param touching_dot: bool - is the player touching a dot? + :return: bool + """ + return (touching_power_pellet is True) | (touching_dot is True) + + +def lose(power_pellet_active, touching_ghost): + """ + + :param power_pellet_active: bool - does the player have an active power pellet? + :param touching_ghost: bool - is the player touching a ghost? + :return: bool + """ + return (power_pellet_active is False) & (touching_ghost is True) + + +def win(has_eaten_all_dots, power_pellet_active, touching_ghost): + """ + + :param has_eaten_all_dots: bool - has the player "eaten" all the dots? + :param power_pellet_active: bool - does the player have an active power pellet? + :param touching_ghost: bool - is the player touching a ghost? + :return: bool + """ + return (has_eaten_all_dots == True) & (lose(power_pellet_active, touching_ghost) != True) From 97f6792a1712d94f52015dfa25bceab6cf6fcd9b Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:39 +0000 Subject: [PATCH 40/74] [Sync Iteration] python/ghost-gobble-arcade-game/5 --- .../ghost-gobble-arcade-game/5/arcade_game.py | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 solutions/python/ghost-gobble-arcade-game/5/arcade_game.py diff --git a/solutions/python/ghost-gobble-arcade-game/5/arcade_game.py b/solutions/python/ghost-gobble-arcade-game/5/arcade_game.py new file mode 100644 index 00000000000..1735565a868 --- /dev/null +++ b/solutions/python/ghost-gobble-arcade-game/5/arcade_game.py @@ -0,0 +1,39 @@ +def eat_ghost(power_pellet_active, touching_ghost): + """ + + :param power_pellet_active: bool - does the player have an active power pellet? + :param touching_ghost: bool - is the player touching a ghost? + :return: bool + """ + return (power_pellet_active is True) & (touching_ghost is True) + + +def score(touching_power_pellet, touching_dot): + """ + + :param touching_power_pellet: bool - does the player have an active power pellet? + :param touching_dot: bool - is the player touching a dot? + :return: bool + """ + return (touching_power_pellet is True) | (touching_dot is True) + + +def lose(power_pellet_active, touching_ghost): + """ + + :param power_pellet_active: bool - does the player have an active power pellet? + :param touching_ghost: bool - is the player touching a ghost? + :return: bool + """ + return (power_pellet_active is False) & (touching_ghost is True) + + +def win(has_eaten_all_dots, power_pellet_active, touching_ghost): + """ + + :param has_eaten_all_dots: bool - has the player "eaten" all the dots? + :param power_pellet_active: bool - does the player have an active power pellet? + :param touching_ghost: bool - is the player touching a ghost? + :return: bool + """ + return (has_eaten_all_dots is True) & (lose(power_pellet_active, touching_ghost) is not True) From 22cf923b27ecf0d565f317afcbf3e7cf5d3afc51 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:39 +0000 Subject: [PATCH 41/74] [Sync Iteration] python/ghost-gobble-arcade-game/6 --- .../ghost-gobble-arcade-game/6/arcade_game.py | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 solutions/python/ghost-gobble-arcade-game/6/arcade_game.py diff --git a/solutions/python/ghost-gobble-arcade-game/6/arcade_game.py b/solutions/python/ghost-gobble-arcade-game/6/arcade_game.py new file mode 100644 index 00000000000..b8f0fca1654 --- /dev/null +++ b/solutions/python/ghost-gobble-arcade-game/6/arcade_game.py @@ -0,0 +1,41 @@ +""" Ghost Gobble Arcade Game """ + +def eat_ghost(power_pellet_active, touching_ghost): + """ + + :param power_pellet_active: bool - does the player have an active power pellet? + :param touching_ghost: bool - is the player touching a ghost? + :return: bool + """ + return (power_pellet_active is True) & (touching_ghost is True) + + +def score(touching_power_pellet, touching_dot): + """ + + :param touching_power_pellet: bool - does the player have an active power pellet? + :param touching_dot: bool - is the player touching a dot? + :return: bool + """ + return (touching_power_pellet is True) | (touching_dot is True) + + +def lose(power_pellet_active, touching_ghost): + """ + + :param power_pellet_active: bool - does the player have an active power pellet? + :param touching_ghost: bool - is the player touching a ghost? + :return: bool + """ + return (power_pellet_active is False) & (touching_ghost is True) + + +def win(has_eaten_all_dots, power_pellet_active, touching_ghost): + """ + + :param has_eaten_all_dots: bool - has the player "eaten" all the dots? + :param power_pellet_active: bool - does the player have an active power pellet? + :param touching_ghost: bool - is the player touching a ghost? + :return: bool + """ + return (has_eaten_all_dots is True) & (lose(power_pellet_active, touching_ghost) is not True) From 6967d82c31a3dcd61ed46f99ed24cf82699eb8bb Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:40 +0000 Subject: [PATCH 42/74] [Sync Iteration] python/black-jack/1 --- solutions/python/black-jack/1/black_jack.py | 76 +++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 solutions/python/black-jack/1/black_jack.py diff --git a/solutions/python/black-jack/1/black_jack.py b/solutions/python/black-jack/1/black_jack.py new file mode 100644 index 00000000000..73d8d267ba4 --- /dev/null +++ b/solutions/python/black-jack/1/black_jack.py @@ -0,0 +1,76 @@ +"""Functions to help play and score a game of blackjack. + +How to play blackjack: https://bicyclecards.com/how-to-play/blackjack/ +"Standard" playing cards: https://en.wikipedia.org/wiki/Standard_52-card_deck +""" + + +def value_of_card(card): + """Determine the scoring value of a card. + + :param card: str - given card. + :return: int - value of a given card (J, Q, K = 10, 'A' = 1) numerical value otherwise. + """ + + if card.lower() == "k" or card.lower() == "j" or card.lower() == "q": + return 10 + if card.lower() == "a": + return 1 + return int(card) + + + +print(value_of_card("J")) + + + +print(value_of_card("J")) + +def higher_card(card_one, card_two): + """Determine which card has a higher value in the hand. + + :param card_one, card_two: str - cards dealt. J, Q, K = 10, 'A' = 1, all others are numerical value. + :return: higher value card - str. Tuple of both cards if they are of equal value. + """ + + pass + + +def value_of_ace(card_one, card_two): + """Calculate the most advantageous value for the ace card. + + :param card_one, card_two: str - card (J, Q, K == 10, numerical value otherwise) + :return: int - value of the upcoming ace card (either 1 or 11). + """ + + pass + + +def is_blackjack(card_one, card_two): + """Determine if the hand is a 'natural' or 'blackjack'. + + :param card_one, card_two: str - cards dealt. J, Q, K = 10, 'A' = 11, all others are numerical value. + :return: bool - if the hand is a blackjack (two cards worth 21). + """ + + pass + + +def can_split_pairs(card_one, card_two): + """Determine if a player can split their hand into two hands. + + :param card_one, card_two: str - cards in hand. + :return: bool - if the hand can be split into two pairs (i.e. cards are of the same value). + """ + + pass + + +def can_double_down(card_one, card_two): + """Determine if a blackjack player can place a double down bet. + + :param card_one, card_two: str - first and second cards in hand. + :return: bool - if the hand can be doubled down (i.e. totals 9, 10 or 11 points). + """ + + pass From 349db07f1b7513e69b547dee17c3e5b677758a39 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:40 +0000 Subject: [PATCH 43/74] [Sync Iteration] python/black-jack/2 --- solutions/python/black-jack/2/black_jack.py | 87 +++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 solutions/python/black-jack/2/black_jack.py diff --git a/solutions/python/black-jack/2/black_jack.py b/solutions/python/black-jack/2/black_jack.py new file mode 100644 index 00000000000..bba35afc96a --- /dev/null +++ b/solutions/python/black-jack/2/black_jack.py @@ -0,0 +1,87 @@ +"""Functions to help play and score a game of blackjack. + +How to play blackjack: https://bicyclecards.com/how-to-play/blackjack/ +"Standard" playing cards: https://en.wikipedia.org/wiki/Standard_52-card_deck +""" + + +def value_of_card(card): + """Determine the scoring value of a card. + + :param card: str - given card. + :return: int - value of a given card (J, Q, K = 10, 'A' = 1) numerical value otherwise. + """ + + if card.lower() == "k" or card.lower() == "j" or card.lower() == "q": + return 10 + if card.lower() == "a": + return 1 + return int(card) + +def higher_card(card_one, card_two): + """Determine which card has a higher value in the hand. + + :param card_one, card_two: str - cards dealt. J, Q, K = 10, 'A' = 1, all others are numerical value. + :return: higher value card - str. Tuple of both cards if they are of equal value. + """ + + card_one_value = 0 + card_two_value = 0 + if card_one.lower() == "k" or card_one.lower() == "j" or card_one.lower() == "q": + card_one_value = 10 + if card_two.lower() == "k" or card_two.lower() == "j" or card_two.lower() == "q": + card_two_value = 10 + if card_one.lower() == "a": + card_one_value = 1 + if card_two.lower() == "a": + card_two_value = 1 + if card_one.lower != "a" and card_one.lower() != "k" and card_one.lower() != "j" and card_one.lower() != "q": + card_one_value = int(card_one) + if card_two.lower != "a" and card_two.lower() != "k" and card_two.lower() != "j" and card_two.lower() != "q": + card_two_value = int(card_two) + if card_one_value == card_two_value: + return card_one, card_two + elif card_one_value > card_two_value: + return card_one + else: + return card_two + + +def value_of_ace(card_one, card_two): + """Calculate the most advantageous value for the ace card. + + :param card_one, card_two: str - card (J, Q, K == 10, numerical value otherwise) + :return: int - value of the upcoming ace card (either 1 or 11). + """ + + pass + + +def is_blackjack(card_one, card_two): + """Determine if the hand is a 'natural' or 'blackjack'. + + :param card_one, card_two: str - cards dealt. J, Q, K = 10, 'A' = 11, all others are numerical value. + :return: bool - if the hand is a blackjack (two cards worth 21). + """ + + pass + + +def can_split_pairs(card_one, card_two): + """Determine if a player can split their hand into two hands. + + :param card_one, card_two: str - cards in hand. + :return: bool - if the hand can be split into two pairs (i.e. cards are of the same value). + """ + + pass + + +def can_double_down(card_one, card_two): + """Determine if a blackjack player can place a double down bet. + + :param card_one, card_two: str - first and second cards in hand. + :return: bool - if the hand can be doubled down (i.e. totals 9, 10 or 11 points). + """ + + pass From bc6d7009c2387609ef2b6929f3511f797c7adb70 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:40 +0000 Subject: [PATCH 44/74] [Sync Iteration] python/black-jack/3 --- solutions/python/black-jack/3/black_jack.py | 73 +++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 solutions/python/black-jack/3/black_jack.py diff --git a/solutions/python/black-jack/3/black_jack.py b/solutions/python/black-jack/3/black_jack.py new file mode 100644 index 00000000000..a6245142a7f --- /dev/null +++ b/solutions/python/black-jack/3/black_jack.py @@ -0,0 +1,73 @@ +"""Functions to help play and score a game of blackjack. + +How to play blackjack: https://bicyclecards.com/how-to-play/blackjack/ +"Standard" playing cards: https://en.wikipedia.org/wiki/Standard_52-card_deck +""" + + +def value_of_card(card): + """Determine the scoring value of a card. + + :param card: str - given card. + :return: int - value of a given card (J, Q, K = 10, 'A' = 1) numerical value otherwise. + """ + + if card.lower() == "k" or card.lower() == "j" or card.lower() == "q": + return 10 + if card.lower() == "a": + return 1 + return int(card) + +def higher_card(card_one, card_two): + """Determine which card has a higher value in the hand. + + :param card_one, card_two: str - cards dealt. J, Q, K = 10, 'A' = 1, all others are numerical value. + :return: higher value card - str. Tuple of both cards if they are of equal value. + """ + if (value_of_card(card_one) > value_of_card(card_two)): + return card_one + elif value_of_card(card_one) == value_of_card(card_two): + return card_one, card_two + else: + return card_two + + + +def value_of_ace(card_one, card_two): + """Calculate the most advantageous value for the ace card. + + :param card_one, card_two: str - card (J, Q, K == 10, numerical value otherwise) + :return: int - value of the upcoming ace card (either 1 or 11). + """ + + pass + + +def is_blackjack(card_one, card_two): + """Determine if the hand is a 'natural' or 'blackjack'. + + :param card_one, card_two: str - cards dealt. J, Q, K = 10, 'A' = 11, all others are numerical value. + :return: bool - if the hand is a blackjack (two cards worth 21). + """ + + pass + + +def can_split_pairs(card_one, card_two): + """Determine if a player can split their hand into two hands. + + :param card_one, card_two: str - cards in hand. + :return: bool - if the hand can be split into two pairs (i.e. cards are of the same value). + """ + + pass + + +def can_double_down(card_one, card_two): + """Determine if a blackjack player can place a double down bet. + + :param card_one, card_two: str - first and second cards in hand. + :return: bool - if the hand can be doubled down (i.e. totals 9, 10 or 11 points). + """ + + pass From 6447a5c919706832a91d1158c40c1b72babe087f Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:41 +0000 Subject: [PATCH 45/74] [Sync Iteration] python/black-jack/4 --- solutions/python/black-jack/4/black_jack.py | 76 +++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 solutions/python/black-jack/4/black_jack.py diff --git a/solutions/python/black-jack/4/black_jack.py b/solutions/python/black-jack/4/black_jack.py new file mode 100644 index 00000000000..64fe0791f4e --- /dev/null +++ b/solutions/python/black-jack/4/black_jack.py @@ -0,0 +1,76 @@ +"""Functions to help play and score a game of blackjack. + +How to play blackjack: https://bicyclecards.com/how-to-play/blackjack/ +"Standard" playing cards: https://en.wikipedia.org/wiki/Standard_52-card_deck +""" + + +def value_of_card(card): + """Determine the scoring value of a card. + + :param card: str - given card. + :return: int - value of a given card (J, Q, K = 10, 'A' = 1) numerical value otherwise. + """ + + if card.lower() == "k" or card.lower() == "j" or card.lower() == "q": + return 10 + if card.lower() == "a": + return 1 + return int(card) + +def higher_card(card_one, card_two): + """Determine which card has a higher value in the hand. + + :param card_one, card_two: str - cards dealt. J, Q, K = 10, 'A' = 1, all others are numerical value. + :return: higher value card - str. Tuple of both cards if they are of equal value. + """ + if (value_of_card(card_one) > value_of_card(card_two)): + return card_one + elif value_of_card(card_one) == value_of_card(card_two): + return card_one, card_two + else: + return card_two + +def value_of_ace(card_one, card_two): + """Calculate the most advantageous value for the ace card. + + :param card_one, card_two: str - card (J, Q, K == 10, numerical value otherwise) + :return: int - value of the upcoming ace card (either 1 or 11). + """ + + card_one_value = value_of_card(card_one) + card_two_value = value_of_card(card_two) + if card_one_value + card_two_value + 11 > 21: + return 1 + else: + return 11 + + +def is_blackjack(card_one, card_two): + """Determine if the hand is a 'natural' or 'blackjack'. + + :param card_one, card_two: str - cards dealt. J, Q, K = 10, 'A' = 11, all others are numerical value. + :return: bool - if the hand is a blackjack (two cards worth 21). + """ + + pass + + +def can_split_pairs(card_one, card_two): + """Determine if a player can split their hand into two hands. + + :param card_one, card_two: str - cards in hand. + :return: bool - if the hand can be split into two pairs (i.e. cards are of the same value). + """ + + pass + + +def can_double_down(card_one, card_two): + """Determine if a blackjack player can place a double down bet. + + :param card_one, card_two: str - first and second cards in hand. + :return: bool - if the hand can be doubled down (i.e. totals 9, 10 or 11 points). + """ + + pass From 2ebcb0d904777d9daac17a5ec6f76d3b030375d0 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:41 +0000 Subject: [PATCH 46/74] [Sync Iteration] python/black-jack/5 --- solutions/python/black-jack/5/black_jack.py | 84 +++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 solutions/python/black-jack/5/black_jack.py diff --git a/solutions/python/black-jack/5/black_jack.py b/solutions/python/black-jack/5/black_jack.py new file mode 100644 index 00000000000..2f2e8556281 --- /dev/null +++ b/solutions/python/black-jack/5/black_jack.py @@ -0,0 +1,84 @@ +"""Functions to help play and score a game of blackjack. + +How to play blackjack: https://bicyclecards.com/how-to-play/blackjack/ +"Standard" playing cards: https://en.wikipedia.org/wiki/Standard_52-card_deck +""" + + +def value_of_card(card): + """Determine the scoring value of a card. + + :param card: str - given card. + :return: int - value of a given card (J, Q, K = 10, 'A' = 1) numerical value otherwise. + """ + + if card.lower() == "k" or card.lower() == "j" or card.lower() == "q": + return 10 + if card.lower() == "a": + return 1 + return int(card) + +def higher_card(card_one, card_two): + """Determine which card has a higher value in the hand. + + :param card_one, card_two: str - cards dealt. J, Q, K = 10, 'A' = 1, all others are numerical value. + :return: higher value card - str. Tuple of both cards if they are of equal value. + """ + if (value_of_card(card_one) > value_of_card(card_two)): + return card_one + elif value_of_card(card_one) == value_of_card(card_two): + return card_one, card_two + else: + return card_two + +def value_of_ace(card_one, card_two): + """Calculate the most advantageous value for the ace card. + + :param card_one, card_two: str - card (J, Q, K == 10, numerical value otherwise) + :return: int - value of the upcoming ace card (either 1 or 11). + """ + + card_one_value = value_of_card(card_one) + card_two_value = value_of_card(card_two) + if card_one_value + card_two_value + 11 > 21: + return 1 + else: + return 11 + +def is_blackjack(card_one, card_two): + """Determine if the hand is a 'natural' or 'blackjack'. + + :param card_one, card_two: str - cards dealt. J, Q, K = 10, 'A' = 11, all others are numerical value. + :return: bool - if the hand is a blackjack (two cards worth 21). + """ + + card_one_value = value_of_card(card_one) + card_two_value = value_of_card(card_two) + if card_one.lower() == "a": + card_one_value = 11 + if card_two.lower() == "a": + card_two_value = 11 + if card_one_value + card_two_value == 21: + return True + else: + return False + + +def can_split_pairs(card_one, card_two): + """Determine if a player can split their hand into two hands. + + :param card_one, card_two: str - cards in hand. + :return: bool - if the hand can be split into two pairs (i.e. cards are of the same value). + """ + + pass + + +def can_double_down(card_one, card_two): + """Determine if a blackjack player can place a double down bet. + + :param card_one, card_two: str - first and second cards in hand. + :return: bool - if the hand can be doubled down (i.e. totals 9, 10 or 11 points). + """ + + pass From 7da1bf7e932007596e73ae3ea53111229e03b480 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:42 +0000 Subject: [PATCH 47/74] [Sync Iteration] python/black-jack/6 --- solutions/python/black-jack/6/black_jack.py | 80 +++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 solutions/python/black-jack/6/black_jack.py diff --git a/solutions/python/black-jack/6/black_jack.py b/solutions/python/black-jack/6/black_jack.py new file mode 100644 index 00000000000..1b7ec568f11 --- /dev/null +++ b/solutions/python/black-jack/6/black_jack.py @@ -0,0 +1,80 @@ +"""Functions to help play and score a game of blackjack. + +How to play blackjack: https://bicyclecards.com/how-to-play/blackjack/ +"Standard" playing cards: https://en.wikipedia.org/wiki/Standard_52-card_deck +""" + + +def value_of_card(card): + """Determine the scoring value of a card. + + :param card: str - given card. + :return: int - value of a given card (J, Q, K = 10, 'A' = 1) numerical value otherwise. + """ + + if card.lower() == "k" or card.lower() == "j" or card.lower() == "q": + return 10 + if card.lower() == "a": + return 1 + return int(card) + +def higher_card(card_one, card_two): + """Determine which card has a higher value in the hand. + + :param card_one, card_two: str - cards dealt. J, Q, K = 10, 'A' = 1, all others are numerical value. + :return: higher value card - str. Tuple of both cards if they are of equal value. + """ + if (value_of_card(card_one) > value_of_card(card_two)): + return card_one + elif value_of_card(card_one) == value_of_card(card_two): + return card_one, card_two + else: + return card_two + +def value_of_ace(card_one, card_two): + """Calculate the most advantageous value for the ace card. + + :param card_one, card_two: str - card (J, Q, K == 10, numerical value otherwise) + :return: int - value of the upcoming ace card (either 1 or 11). + """ + + card_one_value = value_of_card(card_one) + card_two_value = value_of_card(card_two) + if card_one_value + card_two_value + 11 > 21: + return 1 + else: + return 11 + +print(value_of_ace('5', 'A')) + +def is_blackjack(card_one, card_two): + """Determine if the hand is a 'natural' or 'blackjack'. + + :param card_one, card_two: str - cards dealt. J, Q, K = 10, 'A' = 11, all others are numerical value. + :return: bool - if the hand is a blackjack (two cards worth 21). + """ + dix =['J', 'Q', 'K' '10'] + if ((card_one in dix) and (card_two == 'A')) or ((card_one == 'A') and (card_two in dix)): + return True + else: + return False + + +def can_split_pairs(card_one, card_two): + """Determine if a player can split their hand into two hands. + + :param card_one, card_two: str - cards in hand. + :return: bool - if the hand can be split into two pairs (i.e. cards are of the same value). + """ + + pass + + +def can_double_down(card_one, card_two): + """Determine if a blackjack player can place a double down bet. + + :param card_one, card_two: str - first and second cards in hand. + :return: bool - if the hand can be doubled down (i.e. totals 9, 10 or 11 points). + """ + + pass From f413dfcb9c33ab1597243fd7f9d005d7def20ad2 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:42 +0000 Subject: [PATCH 48/74] [Sync Iteration] python/black-jack/7 --- solutions/python/black-jack/7/black_jack.py | 82 +++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 solutions/python/black-jack/7/black_jack.py diff --git a/solutions/python/black-jack/7/black_jack.py b/solutions/python/black-jack/7/black_jack.py new file mode 100644 index 00000000000..87effa0dd39 --- /dev/null +++ b/solutions/python/black-jack/7/black_jack.py @@ -0,0 +1,82 @@ +"""Functions to help play and score a game of blackjack. + +How to play blackjack: https://bicyclecards.com/how-to-play/blackjack/ +"Standard" playing cards: https://en.wikipedia.org/wiki/Standard_52-card_deck +""" + + +def value_of_card(card): + """Determine the scoring value of a card. + + :param card: str - given card. + :return: int - value of a given card (J, Q, K = 10, 'A' = 1) numerical value otherwise. + """ + + if card.lower() == "k" or card.lower() == "j" or card.lower() == "q": + return 10 + if card.lower() == "a": + return 1 + return int(card) + +def higher_card(card_one, card_two): + """Determine which card has a higher value in the hand. + + :param card_one, card_two: str - cards dealt. J, Q, K = 10, 'A' = 1, all others are numerical value. + :return: higher value card - str. Tuple of both cards if they are of equal value. + """ + if (value_of_card(card_one) > value_of_card(card_two)): + return card_one + elif value_of_card(card_one) == value_of_card(card_two): + return card_one, card_two + else: + return card_two + +def value_of_ace(card_one, card_two): + """Calculate the most advantageous value for the ace card. + + :param card_one, card_two: str - card (J, Q, K == 10, numerical value otherwise) + :return: int - value of the upcoming ace card (either 1 or 11). + """ + + card_one_value = value_of_card(card_one) + card_two_value = value_of_card(card_two) + if card_one_value + card_two_value + 11 > 21: + return 1 + else: + return 11 + +print(value_of_ace('5', 'A')) + +def is_blackjack(card_one, card_two): + """Determine if the hand is a 'natural' or 'blackjack'. + + :param card_one, card_two: str - cards dealt. J, Q, K = 10, 'A' = 11, all others are numerical value. + :return: bool - if the hand is a blackjack (two cards worth 21). + """ + dix = ['j', 'q', 'k', '10'] + if ((card_one.lower() in dix) and (card_two.lower() == 'a')) or ((card_one.lower() == 'a') and (card_two.lower() in dix)): + return True + else: + return False + +print(is_blackjack('A', 'K')) +print(is_blackjack('10', 'A')) + +def can_split_pairs(card_one, card_two): + """Determine if a player can split their hand into two hands. + + :param card_one, card_two: str - cards in hand. + :return: bool - if the hand can be split into two pairs (i.e. cards are of the same value). + """ + + pass + + +def can_double_down(card_one, card_two): + """Determine if a blackjack player can place a double down bet. + + :param card_one, card_two: str - first and second cards in hand. + :return: bool - if the hand can be doubled down (i.e. totals 9, 10 or 11 points). + """ + + pass From 1130c449896105e2fd7e6d718699890204d00b4c Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:43 +0000 Subject: [PATCH 49/74] [Sync Iteration] python/black-jack/8 --- solutions/python/black-jack/8/black_jack.py | 75 +++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 solutions/python/black-jack/8/black_jack.py diff --git a/solutions/python/black-jack/8/black_jack.py b/solutions/python/black-jack/8/black_jack.py new file mode 100644 index 00000000000..6fd819fd4ee --- /dev/null +++ b/solutions/python/black-jack/8/black_jack.py @@ -0,0 +1,75 @@ +"""Functions to help play and score a game of blackjack. + +How to play blackjack: https://bicyclecards.com/how-to-play/blackjack/ +"Standard" playing cards: https://en.wikipedia.org/wiki/Standard_52-card_deck +""" + + +def value_of_card(card): + """Determine the scoring value of a card. + + :param card: str - given card. + :return: int - value of a given card (J, Q, K = 10, 'A' = 1) numerical value otherwise. + """ + + if card.lower() == "k" or card.lower() == "j" or card.lower() == "q": + return 10 + if card.lower() == "a": + return 1 + return int(card) + +def higher_card(card_one, card_two): + """Determine which card has a higher value in the hand. + + :param card_one, card_two: str - cards dealt. J, Q, K = 10, 'A' = 1, all others are numerical value. + :return: higher value card - str. Tuple of both cards if they are of equal value. + """ + if (value_of_card(card_one) > value_of_card(card_two)): + return card_one + elif value_of_card(card_one) == value_of_card(card_two): + return card_one, card_two + else: + return card_two + +def value_of_ace(card_one, card_two): + """Calculate the most advantageous value for the ace card. + + :param card_one, card_two: str - card (J, Q, K == 10, numerical value otherwise) + :return: int - value of the upcoming ace card (either 1 or 11). + """ + + card_one_value = value_of_card(card_one) + card_two_value = value_of_card(card_two) + if card_one_value + card_two_value + 11 > 21: + return 1 + else: + return 11 + +def is_blackjack(card_one, card_two): + """Determine if the hand is a 'natural' or 'blackjack'. + + :param card_one, card_two: str - cards dealt. J, Q, K = 10, 'A' = 11, all others are numerical value. + :return: bool - if the hand is a blackjack (two cards worth 21). + """ + dix = ['j', 'q', 'k', '10'] + return ((card_one.lower() in dix) and (card_two.lower() == 'a')) or ((card_one.lower() == 'a') and (card_two.lower() in dix)) + +def can_split_pairs(card_one, card_two): + """Determine if a player can split their hand into two hands. + + :param card_one, card_two: str - cards in hand. + :return: bool - if the hand can be split into two pairs (i.e. cards are of the same value). + """ + + return value_of_card(card_one) == value_of_card(card_two) + + +def can_double_down(card_one, card_two): + """Determine if a blackjack player can place a double down bet. + + :param card_one, card_two: str - first and second cards in hand. + :return: bool - if the hand can be doubled down (i.e. totals 9, 10 or 11 points). + """ + + totaux = [9, 10, 11] + return (value_of_card(card_one) + value_of_card(card_two)) in totaux From b011fed16c15163d6f923ccb977f536753ea5bfd Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:43 +0000 Subject: [PATCH 50/74] [Sync Iteration] python/inventory-management/1 --- .../python/inventory-management/1/dicts.py | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 solutions/python/inventory-management/1/dicts.py diff --git a/solutions/python/inventory-management/1/dicts.py b/solutions/python/inventory-management/1/dicts.py new file mode 100644 index 00000000000..6c61b03e02e --- /dev/null +++ b/solutions/python/inventory-management/1/dicts.py @@ -0,0 +1,66 @@ +""" Inventory Management """ + +def create_inventory(items): + """ + + :param items: list - list of items to create an inventory from. + :return: dict - the inventory dictionary. + """ + + liste_sans_double = list(dict.fromkeys(items)) + resultat = {liste_sans_double[i]: items.count(liste_sans_double[i]) for i in range(len(liste_sans_double))} + return resultat + + +def add_items(inventory, items): + """ + + :param inventory: dict - dictionary of existing inventory. + :param items: list - list of items to update the inventory with. + :return: dict - the inventory dictionary update with the new items. + """ + + for item in items: + inventory.setdefault(item, 0) + inventory[item] += 1 + return inventory + + +def decrement_items(inventory, items): + """ + + :param inventory: dict - inventory dictionary. + :param items: list - list of items to decrement from the inventory. + :return: dict - updated inventory dictionary with items decremented. + """ + + for item in items: + if inventory[item] >= 1: + inventory[item] -= 1 + return inventory + + +def remove_item(inventory, item): + """ + :param inventory: dict - inventory dictionary. + :param item: str - item to remove from the inventory. + :return: dict - updated inventory dictionary with item removed. + """ + + if item in inventory: + del inventory[item] + return inventory + return inventory + + +def list_inventory(inventory): + """ + + :param inventory: dict - an inventory dictionary. + :return: list of tuples - list of key, value pairs from the inventory dictionary. + """ + + for item in list(inventory): + if inventory[item] == 0: + del inventory[item] + return list(inventory.items()) From f2c10c093ca57e39e7c8b57c095aa83cf6fe137d Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:43 +0000 Subject: [PATCH 51/74] [Sync Iteration] python/card-games/1 --- solutions/python/card-games/1/lists.py | 103 +++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 solutions/python/card-games/1/lists.py diff --git a/solutions/python/card-games/1/lists.py b/solutions/python/card-games/1/lists.py new file mode 100644 index 00000000000..cc858520002 --- /dev/null +++ b/solutions/python/card-games/1/lists.py @@ -0,0 +1,103 @@ +def get_rounds(number): + """ + + :param number: int - current round number. + :return: list - current round and the two that follow. + """ + rounds = [] + for i in range(3): + rounds.append(number) + number += 1 + return rounds + +def concatenate_rounds(rounds_1, rounds_2): + """ + + :param rounds_1: list - first rounds played. + :param rounds_2: list - second set of rounds played. + :return: list - all rounds played. + """ + if rounds_1 != [] and rounds_2 != []: + return rounds_1.extend(rounds_2) + elif rounds_1 != [] and rounds_2 == []: + return rounds_1 + elif rounds_1 == [] and rounds_2 != []: + return rounds_2 + else: + return [] + + +def list_contains_round(rounds, number): + """ + + :param rounds: list - rounds played. + :param number: int - round number. + :return: bool - was the round played? + """ + + if number in rounds : + return True + else: + return False + +def card_average(hand): + """ + + :param hand: list - cards in hand. + :return: float - average value of the cards in the hand. + """ + + nbre_card = len(hand) + sum = 0 + for i in range(nbre_card): + sum += hand[i] + return sum / nbre_card + +def approx_average_is_average(hand): + """ + + :param hand: list - cards in hand. + :return: bool - if approximate average equals to the `true average`. + """ + + avg = (len(hand) // 2) + if (hand[avg] == int(card_average(hand))): + return True + else: + return False + +def average_even_is_average_odd(hand): + """ + + :param hand: list - cards in hand. + :return: bool - are even and odd averages equal? + """ + + nbre_card = len(hand) + sum_even = 0 + pair = 0 + impait = 0 + sum_odd = 0 + for i in range(nbre_card): + if i % 2 == 0: + sum_even += hand[i] + pair += 1 + else: + sum_odd += hand[i] + impait += 1 + if (sum_even / pair) == (sum_odd / impait): + return True + else: + return False + + +def maybe_double_last(hand): + """ + + :param hand: list - cards in hand. + :return: list - hand with Jacks (if present) value doubled. + """ + + if hand[-1] == 11: + hand[-1] = 22 + return hand From 249c8e931563356827393473cab3377c94b88dd6 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:44 +0000 Subject: [PATCH 52/74] [Sync Iteration] python/card-games/2 --- solutions/python/card-games/2/lists.py | 96 ++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 solutions/python/card-games/2/lists.py diff --git a/solutions/python/card-games/2/lists.py b/solutions/python/card-games/2/lists.py new file mode 100644 index 00000000000..20c962e4754 --- /dev/null +++ b/solutions/python/card-games/2/lists.py @@ -0,0 +1,96 @@ +def get_rounds(number): + """ + + :param number: int - current round number. + :return: list - current round and the two that follow. + """ + rounds = [] + for i in range(3): + rounds.append(number) + number += 1 + return rounds + +def concatenate_rounds(rounds_1, rounds_2): + """ + + :param rounds_1: list - first rounds played. + :param rounds_2: list - second set of rounds played. + :return: list - all rounds played. + """ + rounds_1.extend(rounds_2) + return rounds_1 + +def list_contains_round(rounds, number): + """ + + :param rounds: list - rounds played. + :param number: int - round number. + :return: bool - was the round played? + """ + + if number in rounds : + return True + else: + return False + +def card_average(hand): + """ + + :param hand: list - cards in hand. + :return: float - average value of the cards in the hand. + """ + + nbre_card = len(hand) + sum = 0 + for i in range(nbre_card): + sum += hand[i] + return sum / nbre_card + +def approx_average_is_average(hand): + """ + + :param hand: list - cards in hand. + :return: bool - if approximate average equals to the `true average`. + """ + + avg = (len(hand) // 2) + if (hand[avg] == int(card_average(hand))): + return True + else: + return False + +def average_even_is_average_odd(hand): + """ + + :param hand: list - cards in hand. + :return: bool - are even and odd averages equal? + """ + + nbre_card = len(hand) + sum_even = 0 + pair = 0 + impait = 0 + sum_odd = 0 + for i in range(nbre_card): + if i % 2 == 0: + sum_even += hand[i] + pair += 1 + else: + sum_odd += hand[i] + impait += 1 + if (sum_even / pair) == (sum_odd / impait): + return True + else: + return False + + +def maybe_double_last(hand): + """ + + :param hand: list - cards in hand. + :return: list - hand with Jacks (if present) value doubled. + """ + + if hand[-1] == 11: + hand[-1] = 22 + return hand From 1bb6676542553080ebcdc57f875502c6fc3395e0 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:44 +0000 Subject: [PATCH 53/74] [Sync Iteration] python/card-games/3 --- solutions/python/card-games/3/lists.py | 95 ++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 solutions/python/card-games/3/lists.py diff --git a/solutions/python/card-games/3/lists.py b/solutions/python/card-games/3/lists.py new file mode 100644 index 00000000000..1f7edf32e89 --- /dev/null +++ b/solutions/python/card-games/3/lists.py @@ -0,0 +1,95 @@ +def get_rounds(number): + """ + + :param number: int - current round number. + :return: list - current round and the two that follow. + """ + rounds = [] + for i in range(3): + rounds.append(number) + number += 1 + return rounds + +def concatenate_rounds(rounds_1, rounds_2): + """ + + :param rounds_1: list - first rounds played. + :param rounds_2: list - second set of rounds played. + :return: list - all rounds played. + """ + rounds_1.extend(rounds_2) + return rounds_1 + +def list_contains_round(rounds, number): + """ + + :param rounds: list - rounds played. + :param number: int - round number. + :return: bool - was the round played? + """ + + if number in rounds : + return True + else: + return False + +def card_average(hand): + """ + + :param hand: list - cards in hand. + :return: float - average value of the cards in the hand. + """ + + nbre_card = len(hand) + sum = 0 + for i in range(nbre_card): + sum += hand[i] + return sum / nbre_card + +def approx_average_is_average(hand): + """ + + :param hand: list - cards in hand. + :return: bool - if approximate average equals to the `true average`. + """ + + if card_average(hand) == hand[(len(hand)) // 2] or card_average(hand) == (hand[0] + hand[-1]) / 2 : + return True + else: + return False + +def average_even_is_average_odd(hand): + """ + + :param hand: list - cards in hand. + :return: bool - are even and odd averages equal? + """ + + nbre_card = len(hand) + sum_even = 0 + pair = 0 + impait = 0 + sum_odd = 0 + for i in range(nbre_card): + if i % 2 == 0: + sum_even += hand[i] + pair += 1 + else: + sum_odd += hand[i] + impait += 1 + if (sum_even / pair) == (sum_odd / impait): + return True + else: + return False + + +def maybe_double_last(hand): + """ + + :param hand: list - cards in hand. + :return: list - hand with Jacks (if present) value doubled. + """ + + if hand[-1] == 11: + hand[-1] = 22 + return hand From 843aa2da29d348a730c0b3d4552bb4bad200fab9 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:45 +0000 Subject: [PATCH 54/74] [Sync Iteration] python/card-games/4 --- solutions/python/card-games/4/lists.py | 83 ++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 solutions/python/card-games/4/lists.py diff --git a/solutions/python/card-games/4/lists.py b/solutions/python/card-games/4/lists.py new file mode 100644 index 00000000000..126a3e12315 --- /dev/null +++ b/solutions/python/card-games/4/lists.py @@ -0,0 +1,83 @@ +""" Card Games """ +def get_rounds(number): + """ + + :param number: int - current round number. + :return: list - current round and the two that follow. + """ + rounds = [] + for _ in range(3): + rounds.append(number) + number += 1 + return rounds + +def concatenate_rounds(rounds_1, rounds_2): + """ + + :param rounds_1: list - first rounds played. + :param rounds_2: list - second set of rounds played. + :return: list - all rounds played. + """ + rounds_1.extend(rounds_2) + return rounds_1 + +def list_contains_round(rounds, number): + """ + + :param rounds: list - rounds played. + :param number: int - round number. + :return: bool - was the round played? + """ + return number in rounds + +def card_average(hand): + """ + + :param hand: list - cards in hand. + :return: float - average value of the cards in the hand. + """ + nbre_card = len(hand) + som = 0 + for i in range(nbre_card): + som += hand[i] + return som / nbre_card + +def approx_average_is_average(hand): + """ + + :param hand: list - cards in hand. + :return: bool - if approximate average equals to the `true average`. + """ + return (card_average(hand) == hand[(len(hand)) // 2]) or (card_average(hand) == (hand[0] + hand[-1]) / 2) + +def average_even_is_average_odd(hand): + """ + + :param hand: list - cards in hand. + :return: bool - are even and odd averages equal? + """ + + nbre_card = len(hand) + sum_even = 0 + pair = 0 + impait = 0 + sum_odd = 0 + for i in range(nbre_card): + if i % 2 == 0: + sum_even += hand[i] + pair += 1 + else: + sum_odd += hand[i] + impait += 1 + return (sum_even / pair) == (sum_odd / impait) + + +def maybe_double_last(hand): + """ + + :param hand: list - cards in hand. + :return: list - hand with Jacks (if present) value doubled. + """ + if hand[-1] == 11: + hand[-1] = 22 + return hand From ec808036449c5efe4ae2e45078e94307ce3b2255 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:45 +0000 Subject: [PATCH 55/74] [Sync Iteration] python/card-games/5 --- solutions/python/card-games/5/lists.py | 83 ++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 solutions/python/card-games/5/lists.py diff --git a/solutions/python/card-games/5/lists.py b/solutions/python/card-games/5/lists.py new file mode 100644 index 00000000000..e40abb4d08e --- /dev/null +++ b/solutions/python/card-games/5/lists.py @@ -0,0 +1,83 @@ +""" Card Games """ +def get_rounds(number): + """ + + :param number: int - current round number. + :return: list - current round and the two that follow. + """ + rounds = [] + for _ in range(3): + rounds.append(number) + number += 1 + return rounds + +def concatenate_rounds(rounds_1, rounds_2): + """ + + :param rounds_1: list - first rounds played. + :param rounds_2: list - second set of rounds played. + :return: list - all rounds played. + """ + rounds_1.extend(rounds_2) + return rounds_1 + +def list_contains_round(rounds, number): + """ + + :param rounds: list - rounds played. + :param number: int - round number. + :return: bool - was the round played? + """ + return number in rounds + +def card_average(hand): + """ + + :param hand: list - cards in hand. + :return: float - average value of the cards in the hand. + """ + nbre_card = len(hand) + som = 0 + for i in range(nbre_card): + som += hand[i] + return som / nbre_card + +def approx_average_is_average(hand): + """ + + :param hand: list - cards in hand. + :return: bool - if approximate average equals to the `true average`. + """ + return (card_average(hand) == hand[(len(hand)) // 2]) or (card_average(hand) == (hand[0] + hand[-1]) / 2) + +def average_even_is_average_odd(hand): + """ + + :param hand: list - cards in hand. + :return: bool - are even and odd averages equal? + """ + + nbre_card = len(hand) + sum_even = 0 + pair = 0 + impait = 0 + sum_odd = 0 + for i in range(nbre_card): + if i % 2 == 0: + sum_even += hand[i] + pair += 1 + else: + sum_odd += hand[i] + impait += 1 + return (sum_even / pair) == (sum_odd / impait) + + +def maybe_double_last(hand): + """ + + :param hand: list - cards in hand. + :return: list - hand with Jacks (if present) value doubled. + """ + if hand[-1] == 11: + hand[-1] = 22 + return hand From 6b05e47ab9aa373893f41bb3308916761eafc2c8 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:46 +0000 Subject: [PATCH 56/74] [Sync Iteration] python/chaitanas-colossal-coaster/1 --- .../1/list_methods.py | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 solutions/python/chaitanas-colossal-coaster/1/list_methods.py diff --git a/solutions/python/chaitanas-colossal-coaster/1/list_methods.py b/solutions/python/chaitanas-colossal-coaster/1/list_methods.py new file mode 100644 index 00000000000..3a14f76e210 --- /dev/null +++ b/solutions/python/chaitanas-colossal-coaster/1/list_methods.py @@ -0,0 +1,97 @@ +""" Chaitana's Colossal Coaster """ + +def add_me_to_the_queue(express_queue, normal_queue, ticket_type, person_name): + """ + + :param express_queue: list - names in the Fast-track queue. + :param normal_queue: list - names in the normal queue. + :param ticket_type: int - type of ticket. 1 = express, 0 = normal. + :param person_name: str - name of person to add to a queue. + :return: list - the (updated) queue the name was added to. + """ + if ticket_type == 1 : + express_queue.append(person_name) + return express_queue + else: + normal_queue.append(person_name) + return normal_queue + + +def find_my_friend(queue, friend_name): + """ + + :param queue: list - names in the queue. + :param friend_name: str - name of friend to find. + :return: int - index at which the friends name was found. + """ + return queue.index(friend_name) + + +def add_me_with_my_friends(queue, index, person_name): + """ + + :param queue: list - names in the queue. + :param index: int - the index at which to add the new name. + :param person_name: str - the name to add. + :return: list - queue updated with new name. + """ + + # new_list = [] + # taille = len(queue) + # for i in range(index + 1): + # if i == index : + # new_list.append(person_name) + # break + # new_list.append(queue[i]) + + # for j in range(taille - index): + # new_list.append(queue[index+j]) + # return new_list + + queue.insert(index, person_name) + return queue + +def remove_the_mean_person(queue, person_name): + """ + + :param queue: list - names in the queue. + :param person_name: str - name of mean person. + :return: list - queue update with the mean persons name removed. + """ + # new_list = [] + # taille = len(queue) + # for i in range(taille): + # if i == queue.index(person_name) : + # continue + # new_list.append(queue[i]) + # return new_list + + queue.remove(person_name) + return queue + +def how_many_namefellows(queue, person_name): + """ + + :param queue: list - names in the queue. + :param person_name: str - name you wish to count or track. + :return: int - the number of times the name appears in the queue. + """ + namefellows = queue.count(person_name) + return namefellows + +def remove_the_last_person(queue): + """ + + :param queue: list - names in the queue. + :return: str - name that has been removed from the end of the queue. + """ + return queue[-1] + +def sorted_names(queue): + """ + + :param queue: list - names in the queue. + :return: list - copy of the queue in alphabetical order. + """ + sorted_list = sorted(queue) + return sorted_list From 73292907cca65c351876add2bfe97b98aa2ce878 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:46 +0000 Subject: [PATCH 57/74] [Sync Iteration] python/chaitanas-colossal-coaster/2 --- .../2/list_methods.py | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 solutions/python/chaitanas-colossal-coaster/2/list_methods.py diff --git a/solutions/python/chaitanas-colossal-coaster/2/list_methods.py b/solutions/python/chaitanas-colossal-coaster/2/list_methods.py new file mode 100644 index 00000000000..4281ca1bee9 --- /dev/null +++ b/solutions/python/chaitanas-colossal-coaster/2/list_methods.py @@ -0,0 +1,98 @@ +""" Chaitana's Colossal Coaster """ + +def add_me_to_the_queue(express_queue, normal_queue, ticket_type, person_name): + """ + + :param express_queue: list - names in the Fast-track queue. + :param normal_queue: list - names in the normal queue. + :param ticket_type: int - type of ticket. 1 = express, 0 = normal. + :param person_name: str - name of person to add to a queue. + :return: list - the (updated) queue the name was added to. + """ + if ticket_type == 1 : + express_queue.append(person_name) + return express_queue + normal_queue.append(person_name) + return normal_queue + + +def find_my_friend(queue, friend_name): + """ + + :param queue: list - names in the queue. + :param friend_name: str - name of friend to find. + :return: int - index at which the friends name was found. + """ + return queue.index(friend_name) + + +def add_me_with_my_friends(queue, index, person_name): + """ + + :param queue: list - names in the queue. + :param index: int - the index at which to add the new name. + :param person_name: str - the name to add. + :return: list - queue updated with new name. + """ + + # new_list = [] + # taille = len(queue) + # for i in range(index + 1): + # if i == index : + # new_list.append(person_name) + # break + # new_list.append(queue[i]) + + # for j in range(taille - index): + # new_list.append(queue[index+j]) + # return new_list + + queue.insert(index, person_name) + return queue + +def remove_the_mean_person(queue, person_name): + """ + + :param queue: list - names in the queue. + :param person_name: str - name of mean person. + :return: list - queue update with the mean persons name removed. + """ + # new_list = [] + # taille = len(queue) + # for i in range(taille): + # if i == queue.index(person_name) : + # continue + # new_list.append(queue[i]) + # return new_list + + queue.remove(person_name) + return queue + +def how_many_namefellows(queue, person_name): + """ + + :param queue: list - names in the queue. + :param person_name: str - name you wish to count or track. + :return: int - the number of times the name appears in the queue. + """ + namefellows = queue.count(person_name) + return namefellows + +def remove_the_last_person(queue): + """ + + :param queue: list - names in the queue. + :return: str - name that has been removed from the end of the queue. + """ + last_person = queue[-1] + queue.remove(last_person) + return last_person + +def sorted_names(queue): + """ + + :param queue: list - names in the queue. + :return: list - copy of the queue in alphabetical order. + """ + sorted_list = sorted(queue) + return sorted_list From 712e0d3d84ab7ef7bf3cf0c91bd74d63fff2fc88 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:46 +0000 Subject: [PATCH 58/74] [Sync Iteration] python/making-the-grade/1 --- solutions/python/making-the-grade/1/loops.py | 98 ++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 solutions/python/making-the-grade/1/loops.py diff --git a/solutions/python/making-the-grade/1/loops.py b/solutions/python/making-the-grade/1/loops.py new file mode 100644 index 00000000000..ab6ed7565f1 --- /dev/null +++ b/solutions/python/making-the-grade/1/loops.py @@ -0,0 +1,98 @@ +def round_scores(student_scores): + """ + :param student_scores: list of student exam scores as float or int. + :return: list of student scores *rounded* to nearest integer value. + """ + + int_list = [] + taille_tab = len(student_scores) + for i in range(taille_tab): + int_list.append(round(student_scores[i])) + return int_list + +def count_failed_students(student_scores): + """ + :param student_scores: list of integer student scores. + :return: integer count of student scores at or below 40. + """ + + failed_students = 0 + taille_tab = len(student_scores) + for i in range(taille_tab): + if student_scores[i] <= 40: + failed_students += 1 + return failed_students + +def above_threshold(student_scores, threshold): + """ + :param student_scores: list of integer scores + :param threshold : integer + :return: list of integer scores that are at or above the "best" threshold. + """ + + best_students_list = [] + taille_tab = len(student_scores) + for i in range(taille_tab): + if student_scores[i] >= threshold: + best_students_list.append(student_scores[i]) + return best_students_list + + +def letter_grades(highest): + """ + :param highest: integer of highest exam score. + :return: list of integer lower threshold scores for each D-A letter grade interval. + For example, where the highest score is 100, and failing is <= 40, + The result would be [41, 56, 71, 86]: + + 41 <= "D" <= 55 + 56 <= "C" <= 70 + 71 <= "B" <= 85 + 86 <= "A" <= 100 + """ + + tab_a = [100, 99, 98] + tab_b = [97, 96, 95, 94] + tab_c = [93, 92, 91, 90] + tab_d = [89, 88, 87, 86] + tab_e = [85, 84, 83, 82] + tab_f = [81, 80, 79, 78] + + if highest in tab_a : + return [41, 56, 71, 86] + if highest in tab_b : + return [41, 55, 69, 83] + if highest in tab_c : + return [41, 54, 67, 80] + if highest in tab_d : + return [41, 53, 65, 77] + if highest in tab_e : + return [41, 52, 63, 74] + if highest in tab_f : + return [41, 51, 61, 71] + +def student_ranking(student_scores, student_names): + """ + :param student_scores: list of scores in descending order. + :param student_names: list of names in descending order by exam score. + :return: list of strings in format [". : "]. + """ + + tab_size = len(student_scores) + tab_student_rank = [] + for i in range(tab_size): + data_of_tab = f"{i+1}. {student_names[i]}: {student_scores[i]}" + tab_student_rank.append(data_of_tab) + return tab_student_rank + + +def perfect_score(student_info): + """ + :param student_info: list of [, ] lists + :return: first `[, 100]` or `[]` if no student score of 100 is found. + """ + tab_size = len(student_info) + for i in range(tab_size): + if student_info[i][-1] == 100: + return student_info[i] + return [] From 7037a8a7ca56898d941290383803324075fcfb4d Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:47 +0000 Subject: [PATCH 59/74] [Sync Iteration] python/making-the-grade/2 --- solutions/python/making-the-grade/2/loops.py | 99 ++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 solutions/python/making-the-grade/2/loops.py diff --git a/solutions/python/making-the-grade/2/loops.py b/solutions/python/making-the-grade/2/loops.py new file mode 100644 index 00000000000..2b3a8c65f98 --- /dev/null +++ b/solutions/python/making-the-grade/2/loops.py @@ -0,0 +1,99 @@ +def round_scores(student_scores): + """ + :param student_scores: list of student exam scores as float or int. + :return: list of student scores *rounded* to nearest integer value. + """ + + int_list = [] + taille_tab = len(student_scores) + for i in range(taille_tab): + int_list.append(round(student_scores[i])) + return int_list + +def count_failed_students(student_scores): + """ + :param student_scores: list of integer student scores. + :return: integer count of student scores at or below 40. + """ + + failed_students = 0 + taille_tab = len(student_scores) + for i in range(taille_tab): + if student_scores[i] <= 40: + failed_students += 1 + return failed_students + +def above_threshold(student_scores, threshold): + """ + :param student_scores: list of integer scores + :param threshold : integer + :return: list of integer scores that are at or above the "best" threshold. + """ + + best_students_list = [] + taille_tab = len(student_scores) + for i in range(taille_tab): + if student_scores[i] >= threshold: + best_students_list.append(student_scores[i]) + return best_students_list + + +def letter_grades(highest): + """ + :param highest: integer of highest exam score. + :return: list of integer lower threshold scores for each D-A letter grade interval. + For example, where the highest score is 100, and failing is <= 40, + The result would be [41, 56, 71, 86]: + + 41 <= "D" <= 55 + 56 <= "C" <= 70 + 71 <= "B" <= 85 + 86 <= "A" <= 100 + """ + + tab_a = [100, 99, 98] + tab_b = [97, 96, 95, 94] + tab_c = [93, 92, 91, 90] + tab_d = [89, 88, 87, 86] + tab_e = [85, 84, 83, 82] + tab_f = [81, 80, 79, 78] + + if highest in tab_a : + return [41, 56, 71, 86] + if highest in tab_b : + return [41, 55, 69, 83] + if highest in tab_c : + return [41, 54, 67, 80] + if highest in tab_d : + return [41, 53, 65, 77] + if highest in tab_e : + return [41, 52, 63, 74] + if highest in tab_f : + return [41, 51, 61, 71] + return None + +def student_ranking(student_scores, student_names): + """ + :param student_scores: list of scores in descending order. + :param student_names: list of names in descending order by exam score. + :return: list of strings in format [". : "]. + """ + + tab_size = len(student_scores) + tab_student_rank = [] + for i in range(tab_size): + data_of_tab = f"{i+1}. {student_names[i]}: {student_scores[i]}" + tab_student_rank.append(data_of_tab) + return tab_student_rank + + +def perfect_score(student_info): + """ + :param student_info: list of [, ] lists + :return: first `[, 100]` or `[]` if no student score of 100 is found. + """ + tab_size = len(student_info) + for i in range(tab_size): + if student_info[i][-1] == 100: + return student_info[i] + return [] From 5c8d0bf214a28a4363b8bcc86b09743753cb4f6f Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:47 +0000 Subject: [PATCH 60/74] [Sync Iteration] python/making-the-grade/3 --- solutions/python/making-the-grade/3/loops.py | 100 +++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 solutions/python/making-the-grade/3/loops.py diff --git a/solutions/python/making-the-grade/3/loops.py b/solutions/python/making-the-grade/3/loops.py new file mode 100644 index 00000000000..b5d83f2b9c1 --- /dev/null +++ b/solutions/python/making-the-grade/3/loops.py @@ -0,0 +1,100 @@ +def round_scores(student_scores): + """ + :param student_scores: list of student exam scores as float or int. + :return: list of student scores *rounded* to nearest integer value. + """ + + int_list = [] + taille_tab = len(student_scores) + for i in range(taille_tab): + int_list.append(round(student_scores[i])) + return int_list + +def count_failed_students(student_scores): + """ + :param student_scores: list of integer student scores. + :return: integer count of student scores at or below 40. + """ + + failed_students = 0 + taille_tab = len(student_scores) + for i in range(taille_tab): + if student_scores[i] <= 40: + failed_students += 1 + return failed_students + +def above_threshold(student_scores, threshold): + """ + :param student_scores: list of integer scores + :param threshold : integer + :return: list of integer scores that are at or above the "best" threshold. + """ + + best_students_list = [] + taille_tab = len(student_scores) + for i in range(taille_tab): + if student_scores[i] >= threshold: + best_students_list.append(student_scores[i]) + return best_students_list + + +def letter_grades(highest): + """ + :param highest: integer of highest exam score. + :return: list of integer lower threshold scores for each D-A letter grade interval. + For example, where the highest score is 100, and failing is <= 40, + The result would be [41, 56, 71, 86]: + + 41 <= "D" <= 55 + 56 <= "C" <= 70 + 71 <= "B" <= 85 + 86 <= "A" <= 100 + """ + + tab_a = [100, 99, 98] + tab_b = [97, 96, 95, 94] + tab_c = [93, 92, 91, 90] + tab_d = [89, 88, 87, 86] + tab_e = [85, 84, 83, 82] + tab_f = [81, 80, 79, 78] + + if highest in tab_a : + return [41, 56, 71, 86] + elif highest in tab_b : + return [41, 55, 69, 83] + elif highest in tab_c : + return [41, 54, 67, 80] + elif highest in tab_d : + return [41, 53, 65, 77] + elif highest in tab_e : + return [41, 52, 63, 74] + elif highest in tab_f : + return [41, 51, 61, 71] + else: + return None + +def student_ranking(student_scores, student_names): + """ + :param student_scores: list of scores in descending order. + :param student_names: list of names in descending order by exam score. + :return: list of strings in format [". : "]. + """ + + tab_size = len(student_scores) + tab_student_rank = [] + for i in range(tab_size): + data_of_tab = f"{i+1}. {student_names[i]}: {student_scores[i]}" + tab_student_rank.append(data_of_tab) + return tab_student_rank + + +def perfect_score(student_info): + """ + :param student_info: list of [, ] lists + :return: first `[, 100]` or `[]` if no student score of 100 is found. + """ + tab_size = len(student_info) + for i in range(tab_size): + if student_info[i][-1] == 100: + return student_info[i] + return [] From 518f4963588dc20eca30dee67d83caaf560f8c54 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:48 +0000 Subject: [PATCH 61/74] [Sync Iteration] python/making-the-grade/4 --- solutions/python/making-the-grade/4/loops.py | 99 ++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 solutions/python/making-the-grade/4/loops.py diff --git a/solutions/python/making-the-grade/4/loops.py b/solutions/python/making-the-grade/4/loops.py new file mode 100644 index 00000000000..2b3a8c65f98 --- /dev/null +++ b/solutions/python/making-the-grade/4/loops.py @@ -0,0 +1,99 @@ +def round_scores(student_scores): + """ + :param student_scores: list of student exam scores as float or int. + :return: list of student scores *rounded* to nearest integer value. + """ + + int_list = [] + taille_tab = len(student_scores) + for i in range(taille_tab): + int_list.append(round(student_scores[i])) + return int_list + +def count_failed_students(student_scores): + """ + :param student_scores: list of integer student scores. + :return: integer count of student scores at or below 40. + """ + + failed_students = 0 + taille_tab = len(student_scores) + for i in range(taille_tab): + if student_scores[i] <= 40: + failed_students += 1 + return failed_students + +def above_threshold(student_scores, threshold): + """ + :param student_scores: list of integer scores + :param threshold : integer + :return: list of integer scores that are at or above the "best" threshold. + """ + + best_students_list = [] + taille_tab = len(student_scores) + for i in range(taille_tab): + if student_scores[i] >= threshold: + best_students_list.append(student_scores[i]) + return best_students_list + + +def letter_grades(highest): + """ + :param highest: integer of highest exam score. + :return: list of integer lower threshold scores for each D-A letter grade interval. + For example, where the highest score is 100, and failing is <= 40, + The result would be [41, 56, 71, 86]: + + 41 <= "D" <= 55 + 56 <= "C" <= 70 + 71 <= "B" <= 85 + 86 <= "A" <= 100 + """ + + tab_a = [100, 99, 98] + tab_b = [97, 96, 95, 94] + tab_c = [93, 92, 91, 90] + tab_d = [89, 88, 87, 86] + tab_e = [85, 84, 83, 82] + tab_f = [81, 80, 79, 78] + + if highest in tab_a : + return [41, 56, 71, 86] + if highest in tab_b : + return [41, 55, 69, 83] + if highest in tab_c : + return [41, 54, 67, 80] + if highest in tab_d : + return [41, 53, 65, 77] + if highest in tab_e : + return [41, 52, 63, 74] + if highest in tab_f : + return [41, 51, 61, 71] + return None + +def student_ranking(student_scores, student_names): + """ + :param student_scores: list of scores in descending order. + :param student_names: list of names in descending order by exam score. + :return: list of strings in format [". : "]. + """ + + tab_size = len(student_scores) + tab_student_rank = [] + for i in range(tab_size): + data_of_tab = f"{i+1}. {student_names[i]}: {student_scores[i]}" + tab_student_rank.append(data_of_tab) + return tab_student_rank + + +def perfect_score(student_info): + """ + :param student_info: list of [, ] lists + :return: first `[, 100]` or `[]` if no student score of 100 is found. + """ + tab_size = len(student_info) + for i in range(tab_size): + if student_info[i][-1] == 100: + return student_info[i] + return [] From 392925c9f70e825f411878fe8acd0ded9c2a7ffa Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:48 +0000 Subject: [PATCH 62/74] [Sync Iteration] python/making-the-grade/5 --- solutions/python/making-the-grade/5/loops.py | 80 ++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 solutions/python/making-the-grade/5/loops.py diff --git a/solutions/python/making-the-grade/5/loops.py b/solutions/python/making-the-grade/5/loops.py new file mode 100644 index 00000000000..eb64a1c602b --- /dev/null +++ b/solutions/python/making-the-grade/5/loops.py @@ -0,0 +1,80 @@ +def round_scores(student_scores): + """ + :param student_scores: list of student exam scores as float or int. + :return: list of student scores *rounded* to nearest integer value. + """ + + int_list = [] + taille_tab = len(student_scores) + for i in range(taille_tab): + int_list.append(round(student_scores[i])) + return int_list + +def count_failed_students(student_scores): + """ + :param student_scores: list of integer student scores. + :return: integer count of student scores at or below 40. + """ + + failed_students = 0 + taille_tab = len(student_scores) + for i in range(taille_tab): + if student_scores[i] <= 40: + failed_students += 1 + return failed_students + +def above_threshold(student_scores, threshold): + """ + :param student_scores: list of integer scores + :param threshold : integer + :return: list of integer scores that are at or above the "best" threshold. + """ + + best_students_list = [] + taille_tab = len(student_scores) + for i in range(taille_tab): + if student_scores[i] >= threshold: + best_students_list.append(student_scores[i]) + return best_students_list + + +def letter_grades(highest): + """ + :param highest: integer of highest exam score. + :return: list of integer lower threshold scores for each D-A letter grade interval. + For example, where the highest score is 100, and failing is <= 40, + The result would be [41, 56, 71, 86]: + + 41 <= "D" <= 55 + 56 <= "C" <= 70 + 71 <= "B" <= 85 + 86 <= "A" <= 100 + """ + threshold = 41 + return list(range(threshold, highest, round((highest - threshold) / 4))) + +def student_ranking(student_scores, student_names): + """ + :param student_scores: list of scores in descending order. + :param student_names: list of names in descending order by exam score. + :return: list of strings in format [". : "]. + """ + + tab_size = len(student_scores) + tab_student_rank = [] + for i in range(tab_size): + data_of_tab = f"{i+1}. {student_names[i]}: {student_scores[i]}" + tab_student_rank.append(data_of_tab) + return tab_student_rank + + +def perfect_score(student_info): + """ + :param student_info: list of [, ] lists + :return: first `[, 100]` or `[]` if no student score of 100 is found. + """ + tab_size = len(student_info) + for i in range(tab_size): + if student_info[i][-1] == 100: + return student_info[i] + return [] From 6d543aa77b3c06cf5ed6e2ef89b308c56a9b7879 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:48 +0000 Subject: [PATCH 63/74] [Sync Iteration] python/making-the-grade/6 --- solutions/python/making-the-grade/6/loops.py | 81 ++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 solutions/python/making-the-grade/6/loops.py diff --git a/solutions/python/making-the-grade/6/loops.py b/solutions/python/making-the-grade/6/loops.py new file mode 100644 index 00000000000..9f3ac88369b --- /dev/null +++ b/solutions/python/making-the-grade/6/loops.py @@ -0,0 +1,81 @@ +""" Making the Grade """ +def round_scores(student_scores): + """ + :param student_scores: list of student exam scores as float or int. + :return: list of student scores *rounded* to nearest integer value. + """ + + int_list = [] + taille_tab = len(student_scores) + for i in range(taille_tab): + int_list.append(round(student_scores[i])) + return int_list + +def count_failed_students(student_scores): + """ + :param student_scores: list of integer student scores. + :return: integer count of student scores at or below 40. + """ + + failed_students = 0 + taille_tab = len(student_scores) + for i in range(taille_tab): + if student_scores[i] <= 40: + failed_students += 1 + return failed_students + +def above_threshold(student_scores, threshold): + """ + :param student_scores: list of integer scores + :param threshold : integer + :return: list of integer scores that are at or above the "best" threshold. + """ + + best_students_list = [] + taille_tab = len(student_scores) + for i in range(taille_tab): + if student_scores[i] >= threshold: + best_students_list.append(student_scores[i]) + return best_students_list + + +def letter_grades(highest): + """ + :param highest: integer of highest exam score. + :return: list of integer lower threshold scores for each D-A letter grade interval. + For example, where the highest score is 100, and failing is <= 40, + The result would be [41, 56, 71, 86]: + + 41 <= "D" <= 55 + 56 <= "C" <= 70 + 71 <= "B" <= 85 + 86 <= "A" <= 100 + """ + threshold = 41 + return list(range(threshold, highest, round((highest - threshold) / 4))) + +def student_ranking(student_scores, student_names): + """ + :param student_scores: list of scores in descending order. + :param student_names: list of names in descending order by exam score. + :return: list of strings in format [". : "]. + """ + + tab_size = len(student_scores) + tab_student_rank = [] + for i in range(tab_size): + data_of_tab = f"{i+1}. {student_names[i]}: {student_scores[i]}" + tab_student_rank.append(data_of_tab) + return tab_student_rank + + +def perfect_score(student_info): + """ + :param student_info: list of [, ] lists + :return: first `[, 100]` or `[]` if no student score of 100 is found. + """ + tab_size = len(student_info) + for i in range(tab_size): + if student_info[i][-1] == 100: + return student_info[i] + return [] From 97907e676963690ccb241fd4de14683d5361f95c Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:49 +0000 Subject: [PATCH 64/74] [Sync Iteration] python/little-sisters-essay/1 --- .../little-sisters-essay/1/string_methods.py | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 solutions/python/little-sisters-essay/1/string_methods.py diff --git a/solutions/python/little-sisters-essay/1/string_methods.py b/solutions/python/little-sisters-essay/1/string_methods.py new file mode 100644 index 00000000000..6f5e7311565 --- /dev/null +++ b/solutions/python/little-sisters-essay/1/string_methods.py @@ -0,0 +1,48 @@ +from pyparsing import Word + + +def capitalize_title(title): + """ + + :param title: str title string that needs title casing + :return: str title string in title case (first letters capitalized) + """ + + return title.title() + + +def check_sentence_ending(sentence): + """ + + :param sentence: str a sentence to check. + :return: bool True if punctuated correctly with period, False otherwise. + """ + + words = sentence.split() + lettres = list(words[-1]) + return lettres[-1] == "." + + + +def clean_up_spacing(sentence): + """ + + :param sentence: str a sentence to clean of leading and trailing space characters. + :return: str a sentence that has been cleaned of leading and trailing space characters. + """ + + return sentence.strip(" ") + + +def replace_word_choice(sentence, old_word, new_word): + """ + + :param sentence: str a sentence to replace words in. + :param old_word: str word to replace + :param new_word: str replacement word + :return: str input sentence with new words in place of old words + """ + + new_sentence = sentence.replace(old_word, new_word) + return new_sentence + From 3097c837e9fe73446ce524ec5bf109675a43249a Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:49 +0000 Subject: [PATCH 65/74] [Sync Iteration] python/little-sisters-essay/2 --- .../little-sisters-essay/2/string_methods.py | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 solutions/python/little-sisters-essay/2/string_methods.py diff --git a/solutions/python/little-sisters-essay/2/string_methods.py b/solutions/python/little-sisters-essay/2/string_methods.py new file mode 100644 index 00000000000..8b019c2ca34 --- /dev/null +++ b/solutions/python/little-sisters-essay/2/string_methods.py @@ -0,0 +1,41 @@ +""" Little Sister's Essay """ +def capitalize_title(title): + """ + + :param title: str title string that needs title casing + :return: str title string in title case (first letters capitalized) + """ + + return title.title() + +def check_sentence_ending(sentence): + """ + + :param sentence: str a sentence to check. + :return: bool True if punctuated correctly with period, False otherwise. + """ + + words = sentence.split() + lettres = list(words[-1]) + return lettres[-1] == "." + +def clean_up_spacing(sentence): + """ + + :param sentence: str a sentence to clean of leading and trailing space characters. + :return: str a sentence that has been cleaned of leading and trailing space characters. + """ + + return sentence.strip(" ") + +def replace_word_choice(sentence, old_word, new_word): + """ + + :param sentence: str a sentence to replace words in. + :param old_word: str word to replace + :param new_word: str replacement word + :return: str input sentence with new words in place of old words + """ + + new_sentence = sentence.replace(old_word, new_word) + return new_sentence From 0226113692d2e2c9f1a1167b82022b59d3e67670 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:50 +0000 Subject: [PATCH 66/74] [Sync Iteration] python/little-sisters-essay/3 --- .../little-sisters-essay/3/string_methods.py | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 solutions/python/little-sisters-essay/3/string_methods.py diff --git a/solutions/python/little-sisters-essay/3/string_methods.py b/solutions/python/little-sisters-essay/3/string_methods.py new file mode 100644 index 00000000000..bbf560bcda1 --- /dev/null +++ b/solutions/python/little-sisters-essay/3/string_methods.py @@ -0,0 +1,41 @@ +""" Little Sister's Essay """ +def capitalize_title(title): + """ + + :param title: str title string that needs title casing + :return: str title string in title case (first letters capitalized) + """ + + return title.title() + +def check_sentence_ending(sentence): + """ + + :param sentence: str a sentence to check. + :return: bool True if punctuated correctly with period, False otherwise. + """ + + words = sentence.split() + lettres = list(words[-1]) + return lettres[-1] == "." + +def clean_up_spacing(sentence): + """ + + :param sentence: str a sentence to clean of leading and trailing space characters. + :return: str a sentence that has been cleaned of leading and trailing space characters. + """ + + return sentence.strip(" ") + +def replace_word_choice(sentence, old_word, new_word): + """ + + :param sentence: str a sentence to replace words in. + :param old_word: str word to replace + :param new_word: str replacement word + :return: str input sentence with new words in place of old words + """ + + new_sentence = sentence.replace(old_word, new_word) + return new_sentence From 163bb78c9fb1d408242c739a95dc83fe0667bd96 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:50 +0000 Subject: [PATCH 67/74] [Sync Iteration] python/currency-exchange/1 --- .../python/currency-exchange/1/exchange.py | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 solutions/python/currency-exchange/1/exchange.py diff --git a/solutions/python/currency-exchange/1/exchange.py b/solutions/python/currency-exchange/1/exchange.py new file mode 100644 index 00000000000..7d1834ba1c4 --- /dev/null +++ b/solutions/python/currency-exchange/1/exchange.py @@ -0,0 +1,72 @@ +def exchange_money(budget, exchange_rate): + """ + + :param budget: float - amount of money you are planning to exchange. + :param exchange_rate: float - unit value of the foreign currency. + :return: float - exchanged value of the foreign currency you can receive. + """ + + return budget / exchange_rate + + +def get_change(budget, exchanging_value): + """ + + :param budget: float - amount of money you own. + :param exchanging_value: int - amount of your money you want to exchange now. + :return: float - amount left of your starting currency after exchanging. + """ + + return budget - exchanging_value + + +def get_value_of_bills(denomination, number_of_bills): + """ + + :param denomination: int - the value of a bill. + :param number_of_bills: int - amount of bills you received. + :return: int - total value of bills you now have. + """ + + return denomination * number_of_bills + + +def get_number_of_bills(budget, denomination): + """ + + :param budget: float - the amount of money you are planning to exchange. + :param denomination: int - the value of a single bill. + :return: int - number of bills after exchanging all your money. + """ + + return budget // denomination + + +def exchangeable_value(budget, exchange_rate, spread, denomination): + """ + + :param budget: float - the amount of your money you are planning to exchange. + :param exchange_rate: float - the unit value of the foreign currency. + :param spread: int - percentage that is taken as an exchange fee. + :param denomination: int - the value of a single bill. + :return: int - maximum value you can get. + """ + intermediaire_exchange = ((exchange_rate * spread) / 100) + new_exchange = exchange_rate + intermediaire_exchange + return int(exchange_money((budget / denomination), new_exchange)) * denomination + + +def non_exchangeable_value(budget, exchange_rate, spread, denomination): + """ + + :param budget: float - the amount of your money you are planning to exchange. + :param exchange_rate: float - the unit value of the foreign currency. + :param spread: int - percentage that is taken as an exchange fee. + :param denomination: int - the value of a single bill. + :return: int non-exchangeable value. + """ + + intermediaire_exchange = ((exchange_rate * spread) / 100) + new_exchange = exchange_rate + intermediaire_exchange + return int(exchange_money(budget, new_exchange) % denomination) + From 23e83d7dce2e7b4542f858cdb55a474614aefa0b Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:51 +0000 Subject: [PATCH 68/74] [Sync Iteration] python/currency-exchange/2 --- .../python/currency-exchange/2/exchange.py | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 solutions/python/currency-exchange/2/exchange.py diff --git a/solutions/python/currency-exchange/2/exchange.py b/solutions/python/currency-exchange/2/exchange.py new file mode 100644 index 00000000000..97824144822 --- /dev/null +++ b/solutions/python/currency-exchange/2/exchange.py @@ -0,0 +1,72 @@ +""" Currency Exchange """ +def exchange_money(budget, exchange_rate): + """ + + :param budget: float - amount of money you are planning to exchange. + :param exchange_rate: float - unit value of the foreign currency. + :return: float - exchanged value of the foreign currency you can receive. + """ + + return budget / exchange_rate + + +def get_change(budget, exchanging_value): + """ + + :param budget: float - amount of money you own. + :param exchanging_value: int - amount of your money you want to exchange now. + :return: float - amount left of your starting currency after exchanging. + """ + + return budget - exchanging_value + + +def get_value_of_bills(denomination, number_of_bills): + """ + + :param denomination: int - the value of a bill. + :param number_of_bills: int - amount of bills you received. + :return: int - total value of bills you now have. + """ + + return denomination * number_of_bills + + +def get_number_of_bills(budget, denomination): + """ + + :param budget: float - the amount of money you are planning to exchange. + :param denomination: int - the value of a single bill. + :return: int - number of bills after exchanging all your money. + """ + + return budget // denomination + + +def exchangeable_value(budget, exchange_rate, spread, denomination): + """ + + :param budget: float - the amount of your money you are planning to exchange. + :param exchange_rate: float - the unit value of the foreign currency. + :param spread: int - percentage that is taken as an exchange fee. + :param denomination: int - the value of a single bill. + :return: int - maximum value you can get. + """ + intermediaire_exchange = ((exchange_rate * spread) / 100) + new_exchange = exchange_rate + intermediaire_exchange + return int(exchange_money((budget / denomination), new_exchange)) * denomination + + +def non_exchangeable_value(budget, exchange_rate, spread, denomination): + """ + + :param budget: float - the amount of your money you are planning to exchange. + :param exchange_rate: float - the unit value of the foreign currency. + :param spread: int - percentage that is taken as an exchange fee. + :param denomination: int - the value of a single bill. + :return: int non-exchangeable value. + """ + + intermediaire_exchange = ((exchange_rate * spread) / 100) + new_exchange = exchange_rate + intermediaire_exchange + return int(exchange_money(budget, new_exchange) % denomination) From e5573c75eaa7dded70baa563b89944f08412e69b Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:51 +0000 Subject: [PATCH 69/74] [Sync Iteration] python/cater-waiter/1 --- solutions/python/cater-waiter/1/sets.py | 133 ++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 solutions/python/cater-waiter/1/sets.py diff --git a/solutions/python/cater-waiter/1/sets.py b/solutions/python/cater-waiter/1/sets.py new file mode 100644 index 00000000000..f393af07060 --- /dev/null +++ b/solutions/python/cater-waiter/1/sets.py @@ -0,0 +1,133 @@ +from unittest import result +from sets_categories_data import (VEGAN, + VEGETARIAN, + KETO, + PALEO, + OMNIVORE, + ALCOHOLS, + SPECIAL_INGREDIENTS) + + +def clean_ingredients(dish_name, dish_ingredients): + """ + + :param dish_name: str + :param dish_ingredients: list + :return: tuple of (dish_name, ingredient set) + + This function should return a `tuple` with the name of the dish as the first item, + followed by the de-duped `set` of ingredients as the second item. + """ + + result = (dish_name, set(dish_ingredients)) + return result + + +def check_drinks(drink_name, drink_ingredients): + """ + + :param drink_name: str + :param drink_ingredients: list + :return: str drink name + ("Mocktail" or "Cocktail") + + The function should return the name of the drink followed by "Mocktail" if the drink has + no alcoholic ingredients, and drink name followed by "Cocktail" if the drink includes alcohol. + """ + + for item in drink_ingredients: + if item in ALCOHOLS: + return f"{drink_name} Cocktail" + return f"{drink_name} Mocktail" + + +def categorize_dish(dish_name, dish_ingredients): + """ + + :param dish_name: str + :param dish_ingredients: list + :return: str "dish name: CATEGORY" + + This function should return a string with the `dish name: ` (which meal category the dish belongs to). + All dishes will "fit" into one of the categories imported from `sets_categories_data.py` + (VEGAN, VEGETARIAN, PALEO, KETO, or OMNIVORE). + """ + + dish_set = set(dish_ingredients) + if dish_set.issubset(VEGAN): + return f"{dish_name}: VEGAN" + elif dish_set.issubset(VEGETARIAN): + return f"{dish_name}: VEGETARIAN" + elif dish_set.issubset(PALEO): + return f"{dish_name}: PALEO" + elif dish_set.issubset(KETO): + return f"{dish_name}: KETO" + else: + return f"{dish_name}: OMNIVORE" + + +def tag_special_ingredients(dish): + """ + + :param dish: tuple of (str of dish name, list of dish ingredients) + :return: tuple of (str of dish name, set of dish special ingredients) + + Return the dish name followed by the `set` of ingredients that require a special note on the dish description. + For the purposes of this exercise, all allergens or special ingredients that need to be tracked are in the + SPECIAL_INGREDIENTS constant imported from `sets_categories_data.py`. + """ + + set_dish = set(dish[1]) + resultat = set_dish.intersection(SPECIAL_INGREDIENTS) + return dish[0], resultat + + +def compile_ingredients(dishes): + """ + + :param dishes: list of dish ingredient sets + :return: set + + This function should return a `set` of all ingredients from all listed dishes. + """ + + resultat = set() + for dish in dishes: + resultat = set.union(resultat, dish) + return resultat + + +def separate_appetizers(dishes, appetizers): + """ + + :param dishes: list of dish names + :param appetizers: list of appetizer names + :return: list of dish names + + The function should return the list of dish names with appetizer names removed. + Either list could contain duplicates and may require de-duping. + """ + + set_dish = set(dishes) + set_appetizer = set(appetizers) + set_result = set_dish.difference(set_appetizer) + return list(set_result) + + +def singleton_ingredients(dishes, intersection): + """ + + :param intersection: constant - one of (VEGAN_INTERSECTION,VEGETARIAN_INTERSECTION,PALEO_INTERSECTION, + KETO_INTERSECTION,OMNIVORE_INTERSECTION) + :param dishes: list of ingredient sets + :return: set of singleton ingredients + + Each dish is represented by a `set` of its ingredients. + Each `_INTERSECTION` is an `intersection` of all dishes in the category. + The function should return a `set` of ingredients that only appear in a single dish. + """ + + resultat = set() + for dish in dishes: + difference = dish.difference(intersection) + resultat = set.union(resultat, difference) + return resultat From 6015c3f40401fe23b52ea9d98381d91f1ddd1e8c Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:52 +0000 Subject: [PATCH 70/74] [Sync Iteration] python/cater-waiter/2 --- solutions/python/cater-waiter/2/sets.py | 133 ++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 solutions/python/cater-waiter/2/sets.py diff --git a/solutions/python/cater-waiter/2/sets.py b/solutions/python/cater-waiter/2/sets.py new file mode 100644 index 00000000000..16f9f82c434 --- /dev/null +++ b/solutions/python/cater-waiter/2/sets.py @@ -0,0 +1,133 @@ +""" Cater Waiter """ +from sets_categories_data import (VEGAN, + VEGETARIAN, + KETO, + PALEO, + OMNIVORE, + ALCOHOLS, + SPECIAL_INGREDIENTS) + + +def clean_ingredients(dish_name, dish_ingredients): + """ + + :param dish_name: str + :param dish_ingredients: list + :return: tuple of (dish_name, ingredient set) + + This function should return a `tuple` with the name of the dish as the first item, + followed by the de-duped `set` of ingredients as the second item. + """ + + resultat = (dish_name, set(dish_ingredients)) + return resultat + + +def check_drinks(drink_name, drink_ingredients): + """ + + :param drink_name: str + :param drink_ingredients: list + :return: str drink name + ("Mocktail" or "Cocktail") + + The function should return the name of the drink followed by "Mocktail" if the drink has + no alcoholic ingredients, and drink name followed by "Cocktail" if the drink includes alcohol. + """ + + for item in drink_ingredients: + if item in ALCOHOLS: + return f"{drink_name} Cocktail" + return f"{drink_name} Mocktail" + + +def categorize_dish(dish_name, dish_ingredients): + """ + + :param dish_name: str + :param dish_ingredients: list + :return: str "dish name: CATEGORY" + + This function should return a string with the `dish name: ` (which meal category the dish belongs to). + All dishes will "fit" into one of the categories imported from `sets_categories_data.py` + (VEGAN, VEGETARIAN, PALEO, KETO, or OMNIVORE). + """ + + dish_set = set(dish_ingredients) + if dish_set.issubset(VEGAN): + return f"{dish_name}: VEGAN" + if dish_set.issubset(VEGETARIAN): + return f"{dish_name}: VEGETARIAN" + if dish_set.issubset(PALEO): + return f"{dish_name}: PALEO" + if dish_set.issubset(KETO): + return f"{dish_name}: KETO" + if dish_set.issubset(OMNIVORE): + return f"{dish_name}: OMNIVORE" + + +def tag_special_ingredients(dish): + """ + + :param dish: tuple of (str of dish name, list of dish ingredients) + :return: tuple of (str of dish name, set of dish special ingredients) + + Return the dish name followed by the `set` of ingredients that require a special note on the dish description. + For the purposes of this exercise, all allergens or special ingredients that need to be tracked are in the + SPECIAL_INGREDIENTS constant imported from `sets_categories_data.py`. + """ + + set_dish = set(dish[1]) + resultat = set_dish.intersection(SPECIAL_INGREDIENTS) + return dish[0], resultat + + +def compile_ingredients(dishes): + """ + + :param dishes: list of dish ingredient sets + :return: set + + This function should return a `set` of all ingredients from all listed dishes. + """ + + resultat = set() + for dish in dishes: + resultat = set.union(resultat, dish) + return resultat + + +def separate_appetizers(dishes, appetizers): + """ + + :param dishes: list of dish names + :param appetizers: list of appetizer names + :return: list of dish names + + The function should return the list of dish names with appetizer names removed. + Either list could contain duplicates and may require de-duping. + """ + + set_dish = set(dishes) + set_appetizer = set(appetizers) + set_result = set_dish.difference(set_appetizer) + return list(set_result) + + +def singleton_ingredients(dishes, intersection): + """ + + :param intersection: constant - one of (VEGAN_INTERSECTION,VEGETARIAN_INTERSECTION,PALEO_INTERSECTION, + KETO_INTERSECTION,OMNIVORE_INTERSECTION) + :param dishes: list of ingredient sets + :return: set of singleton ingredients + + Each dish is represented by a `set` of its ingredients. + Each `_INTERSECTION` is an `intersection` of all dishes in the category. + The function should return a `set` of ingredients that only appear in a single dish. + """ + + resultat = set() + for dish in dishes: + difference = dish.difference(intersection) + resultat = set.union(resultat, difference) + return resultat From 9afca83fd404aa0d36d74ca254de9f0c8d5c0e81 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:52 +0000 Subject: [PATCH 71/74] [Sync Iteration] python/cater-waiter/3 --- solutions/python/cater-waiter/3/sets.py | 134 ++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 solutions/python/cater-waiter/3/sets.py diff --git a/solutions/python/cater-waiter/3/sets.py b/solutions/python/cater-waiter/3/sets.py new file mode 100644 index 00000000000..f505a2b460a --- /dev/null +++ b/solutions/python/cater-waiter/3/sets.py @@ -0,0 +1,134 @@ +""" Cater Waiter """ +from sets_categories_data import (VEGAN, + VEGETARIAN, + KETO, + PALEO, + OMNIVORE, + ALCOHOLS, + SPECIAL_INGREDIENTS) + + +def clean_ingredients(dish_name, dish_ingredients): + """ + + :param dish_name: str + :param dish_ingredients: list + :return: tuple of (dish_name, ingredient set) + + This function should return a `tuple` with the name of the dish as the first item, + followed by the de-duped `set` of ingredients as the second item. + """ + + resultat = (dish_name, set(dish_ingredients)) + return resultat + + +def check_drinks(drink_name, drink_ingredients): + """ + + :param drink_name: str + :param drink_ingredients: list + :return: str drink name + ("Mocktail" or "Cocktail") + + The function should return the name of the drink followed by "Mocktail" if the drink has + no alcoholic ingredients, and drink name followed by "Cocktail" if the drink includes alcohol. + """ + + for item in drink_ingredients: + if item in ALCOHOLS: + return f"{drink_name} Cocktail" + return f"{drink_name} Mocktail" + + +def categorize_dish(dish_name, dish_ingredients): + """ + + :param dish_name: str + :param dish_ingredients: list + :return: str "dish name: CATEGORY" + + This function should return a string with the `dish name: ` (which meal category the dish belongs to). + All dishes will "fit" into one of the categories imported from `sets_categories_data.py` + (VEGAN, VEGETARIAN, PALEO, KETO, or OMNIVORE). + """ + + dish_set = set(dish_ingredients) + if dish_set.issubset(VEGAN): + return f"{dish_name}: VEGAN" + if dish_set.issubset(VEGETARIAN): + return f"{dish_name}: VEGETARIAN" + if dish_set.issubset(PALEO): + return f"{dish_name}: PALEO" + if dish_set.issubset(KETO): + return f"{dish_name}: KETO" + if dish_set.issubset(OMNIVORE): + return f"{dish_name}: OMNIVORE" + return None + + +def tag_special_ingredients(dish): + """ + + :param dish: tuple of (str of dish name, list of dish ingredients) + :return: tuple of (str of dish name, set of dish special ingredients) + + Return the dish name followed by the `set` of ingredients that require a special note on the dish description. + For the purposes of this exercise, all allergens or special ingredients that need to be tracked are in the + SPECIAL_INGREDIENTS constant imported from `sets_categories_data.py`. + """ + + set_dish = set(dish[1]) + resultat = set_dish.intersection(SPECIAL_INGREDIENTS) + return dish[0], resultat + + +def compile_ingredients(dishes): + """ + + :param dishes: list of dish ingredient sets + :return: set + + This function should return a `set` of all ingredients from all listed dishes. + """ + + resultat = set() + for dish in dishes: + resultat = set.union(resultat, dish) + return resultat + + +def separate_appetizers(dishes, appetizers): + """ + + :param dishes: list of dish names + :param appetizers: list of appetizer names + :return: list of dish names + + The function should return the list of dish names with appetizer names removed. + Either list could contain duplicates and may require de-duping. + """ + + set_dish = set(dishes) + set_appetizer = set(appetizers) + set_result = set_dish.difference(set_appetizer) + return list(set_result) + + +def singleton_ingredients(dishes, intersection): + """ + + :param intersection: constant - one of (VEGAN_INTERSECTION,VEGETARIAN_INTERSECTION,PALEO_INTERSECTION, + KETO_INTERSECTION,OMNIVORE_INTERSECTION) + :param dishes: list of ingredient sets + :return: set of singleton ingredients + + Each dish is represented by a `set` of its ingredients. + Each `_INTERSECTION` is an `intersection` of all dishes in the category. + The function should return a `set` of ingredients that only appear in a single dish. + """ + + resultat = set() + for dish in dishes: + difference = dish.difference(intersection) + resultat = set.union(resultat, difference) + return resultat From 1ecb97c50b6bb4d0358ab96cf3a920e7f8716b08 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:53 +0000 Subject: [PATCH 72/74] [Sync Iteration] python/locomotive-engineer/1 --- .../1/locomotive_engineer.py | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 solutions/python/locomotive-engineer/1/locomotive_engineer.py diff --git a/solutions/python/locomotive-engineer/1/locomotive_engineer.py b/solutions/python/locomotive-engineer/1/locomotive_engineer.py new file mode 100644 index 00000000000..ce7fe7ce05c --- /dev/null +++ b/solutions/python/locomotive-engineer/1/locomotive_engineer.py @@ -0,0 +1,60 @@ +"""Functions which helps the locomotive engineer to keep track of the train.""" + + +# TODO: define the 'get_list_of_wagons' function +def get_list_of_wagons(*args): + """Return a list of wagons. + + :param: arbitrary number of wagons. + :return: list - list of wagons. + """ + return list(args) + + +# TODO: define the 'fixListOfWagons()' function +def fix_list_of_wagons(each_wagons_id, missing_wagons): + """Fix the list of wagons. + + :parm each_wagons_id: list - the list of wagons. + :parm missing_wagons: list - the list of missing wagons. + :return: list - list of wagons. + """ + x, y, z, *last = each_wagons_id + return [z, *missing_wagons, *last, x, y] + + +# TODO: define the 'add_missing_stops()' function +def add_missing_stops(route: dict, **kwargs): + """Add missing stops to route dict. + + :param route: dict - the dict of routing information. + :param: arbitrary number of stops. + :return: dict - updated route dictionary. + """ + + return {**route, **{"stops": list(kwargs.values())}} + + +# TODO: define the 'extend_route_information()' function +def extend_route_information(route, more_route_information): + """Extend route information with more_route_information. + + :param route: dict - the route information. + :param more_route_information: dict - extra route information. + :return: dict - extended route information. + """ + return {**route, **more_route_information} + + +# TODO: define the 'fix_wagon_depot()' function +def fix_wagon_depot(wagons_rows): + """Fix the list of rows of wagons. + + :param wagons_rows: list[list[tuple]] - the list of rows of wagons. + :return: list[list[tuple]] - list of rows of wagons. + """ + final_result = [] + partial_result = list(zip(*wagons_rows)) + for i in partial_result: + final_result.append(list(i)) + return final_result From c360aab06cd453800e5ea2fb6ba921939d5e3cc2 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:53 +0000 Subject: [PATCH 73/74] [Sync Iteration] go/hello-world/1 --- solutions/go/hello-world/1/hello_world.go | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 solutions/go/hello-world/1/hello_world.go diff --git a/solutions/go/hello-world/1/hello_world.go b/solutions/go/hello-world/1/hello_world.go new file mode 100644 index 00000000000..3e61875d4b4 --- /dev/null +++ b/solutions/go/hello-world/1/hello_world.go @@ -0,0 +1,6 @@ +package greeting + +// HelloWorld salue le monde. +func HelloWorld() string { + return "Hello, World!" +} From 1c9a40cb16c39f33534130c5e9a1317189f1d738 Mon Sep 17 00:00:00 2001 From: Exercism's Solution Syncer Bot <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:30:54 +0000 Subject: [PATCH 74/74] [Sync Iteration] go/lasagna/1 --- solutions/go/lasagna/1/lasagna.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 solutions/go/lasagna/1/lasagna.go diff --git a/solutions/go/lasagna/1/lasagna.go b/solutions/go/lasagna/1/lasagna.go new file mode 100644 index 00000000000..5d293f28fce --- /dev/null +++ b/solutions/go/lasagna/1/lasagna.go @@ -0,0 +1,22 @@ +package lasagna + +// TODO: define the 'OvenTime' constant +const OvenTime int = 40 + +// RemainingOvenTime returns the remaining minutes based on the `actual` minutes already in the oven. +func RemainingOvenTime(actualMinutesInOven int) int { + //panic("RemainingOvenTime not implemented") + return OvenTime - actualMinutesInOven +} + +// PreparationTime calculates the time needed to prepare the lasagna based on the amount of layers. +func PreparationTime(numberOfLayers int) int { + //panic("PreparationTime not implemented") + return numberOfLayers * 2 +} + +// ElapsedTime calculates the total time needed to create and bake a lasagna. +func ElapsedTime(numberOfLayers, actualMinutesInOven int) int { + //panic("ElapsedTime not implemented") + return (numberOfLayers * 2) + actualMinutesInOven +}