From 2d3442b60a195afcea3c434d2e6cb041f32c670b Mon Sep 17 00:00:00 2001 From: Manu <160436552+manuNikaGod@users.noreply.github.com> Date: Sat, 28 Mar 2026 17:33:36 +0100 Subject: [PATCH 1/5] palindrome --- exercises/hello_world/solution.py | 4 ++-- exercises/palindrome/solution.py | 21 +++++++++------------ 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/exercises/hello_world/solution.py b/exercises/hello_world/solution.py index 19b776e..42e8983 100644 --- a/exercises/hello_world/solution.py +++ b/exercises/hello_world/solution.py @@ -1,4 +1,4 @@ -SUBMIT = False +SUBMIT = True def hello_world() -> str: @@ -8,7 +8,7 @@ def hello_world() -> str: >>> hello_world() 'Hello, World!' """ - return "" + return "Hello, World!" def test() -> None: diff --git a/exercises/palindrome/solution.py b/exercises/palindrome/solution.py index 7664e28..b9b4b9b 100644 --- a/exercises/palindrome/solution.py +++ b/exercises/palindrome/solution.py @@ -1,17 +1,12 @@ -SUBMIT = False +SUBMIT = True -def palindrome(_text: str) -> bool: - # noqa: ARG001 - """Checks if a string is a palindrome. - - Example usage: - >>> palindrome("racecar") - True - >>> palindrome("hello") - False - """ - return False +def palindrome(word:str)->bool: + + for i in range(len(word)): + if word[i]!=word[len(word)-1-i]: + return False + return True def test() -> None: @@ -31,3 +26,5 @@ def test() -> None: if __name__ == "__main__": test() + +print(98) \ No newline at end of file From 999807e828f3bd298e6088d1e645a78fba662207 Mon Sep 17 00:00:00 2001 From: Manu <160436552+manuNikaGod@users.noreply.github.com> Date: Sat, 28 Mar 2026 17:47:41 +0100 Subject: [PATCH 2/5] fibonacci --- exercises/fibonacci/solution.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/exercises/fibonacci/solution.py b/exercises/fibonacci/solution.py index b85766d..7207eb1 100644 --- a/exercises/fibonacci/solution.py +++ b/exercises/fibonacci/solution.py @@ -1,4 +1,4 @@ -SUBMIT = False +SUBMIT = True def fibonacci(n: int) -> int: @@ -14,7 +14,12 @@ def fibonacci(n: int) -> int: >>> fibonacci(10) 55 """ - return 0 + x=1 + y=0 + for i in range(n): + x,y=y,x+y + return y + def test() -> None: From be8e3c1be10a04c87f7964bb94fa37149768e2ab Mon Sep 17 00:00:00 2001 From: Manu <160436552+manuNikaGod@users.noreply.github.com> Date: Sat, 28 Mar 2026 18:14:43 +0100 Subject: [PATCH 3/5] variados --- exercises/celsius_to_fahrenheit/solution.py | 7 +++++-- exercises/personalized_greeting/solution.py | 4 ++-- exercises/simple_interest/solution.py | 5 +++-- exercises/sum_two_numbers/solution.py | 4 ++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/exercises/celsius_to_fahrenheit/solution.py b/exercises/celsius_to_fahrenheit/solution.py index fedf347..ce97bac 100644 --- a/exercises/celsius_to_fahrenheit/solution.py +++ b/exercises/celsius_to_fahrenheit/solution.py @@ -1,4 +1,4 @@ -SUBMIT = False +SUBMIT = True def celsius_to_fahrenheit(_celsius: float) -> float: @@ -13,7 +13,10 @@ def celsius_to_fahrenheit(_celsius: float) -> float: >>> celsius_to_fahrenheit(-40) -40.0 """ - return 0.0 + + farenheit=(_celsius * 9/5)+32 + + return farenheit def test() -> None: diff --git a/exercises/personalized_greeting/solution.py b/exercises/personalized_greeting/solution.py index aed3a12..67fb92a 100644 --- a/exercises/personalized_greeting/solution.py +++ b/exercises/personalized_greeting/solution.py @@ -1,4 +1,4 @@ -SUBMIT = False +SUBMIT = True def personalized_greeting(_name: str, _age: int) -> str: @@ -11,7 +11,7 @@ def personalized_greeting(_name: str, _age: int) -> str: >>> personalized_greeting("Bob", 30) 'Hello Bob, you are 30 years old' """ - return "" + return f"Hello {_name},you are {_age} years old" def test() -> None: diff --git a/exercises/simple_interest/solution.py b/exercises/simple_interest/solution.py index 944bc7f..27c6dab 100644 --- a/exercises/simple_interest/solution.py +++ b/exercises/simple_interest/solution.py @@ -1,4 +1,4 @@ -SUBMIT = False +SUBMIT = True def simple_interest(_principal: float, _rate: float, _time: float) -> float: @@ -11,7 +11,8 @@ def simple_interest(_principal: float, _rate: float, _time: float) -> float: >>> simple_interest(500, 3.5, 1) 17.5 """ - return 0.0 + I=(_principal * _rate * _time) / 100 + return I def test() -> None: diff --git a/exercises/sum_two_numbers/solution.py b/exercises/sum_two_numbers/solution.py index 6bed6c8..b789067 100644 --- a/exercises/sum_two_numbers/solution.py +++ b/exercises/sum_two_numbers/solution.py @@ -1,4 +1,4 @@ -SUBMIT = False +SUBMIT = True def sum_two_numbers(_a: int, _b: int) -> int: @@ -13,7 +13,7 @@ def sum_two_numbers(_a: int, _b: int) -> int: >>> sum_two_numbers(0, 0) 0 """ - return 0 + return _a+_b def test() -> None: From 436cc1082a0a831b787319519be734d0b10b56b5 Mon Sep 17 00:00:00 2001 From: Manu <160436552+manuNikaGod@users.noreply.github.com> Date: Sat, 28 Mar 2026 22:20:53 +0100 Subject: [PATCH 4/5] todos los ejercicios de bucles --- exercises/factorial_iterative/solution.py | 9 +++++-- exercises/linear_search/solution.py | 10 ++++++-- exercises/list_average/solution.py | 7 ++++-- exercises/list_mode/solution.py | 13 ++++++++-- exercises/min_max_list/solution.py | 14 +++++++++-- exercises/prefix_sums/solution.py | 9 +++++-- exercises/prime_check/solution.py | 29 ++++++++++++----------- exercises/variable_swap/solution.py | 3 ++- 8 files changed, 67 insertions(+), 27 deletions(-) diff --git a/exercises/factorial_iterative/solution.py b/exercises/factorial_iterative/solution.py index 78bca9d..1c8e365 100644 --- a/exercises/factorial_iterative/solution.py +++ b/exercises/factorial_iterative/solution.py @@ -1,4 +1,4 @@ -SUBMIT = False +SUBMIT = True def factorial_iterative(_n: int) -> int: @@ -11,7 +11,12 @@ def factorial_iterative(_n: int) -> int: >>> factorial_iterative(5) 120 """ - return 0 + if _n==0: + return 1 + fact=1 + for i in range(1,_n+1): + fact*=i + return fact def test() -> None: diff --git a/exercises/linear_search/solution.py b/exercises/linear_search/solution.py index ad4cb38..7ea070f 100644 --- a/exercises/linear_search/solution.py +++ b/exercises/linear_search/solution.py @@ -1,4 +1,4 @@ -SUBMIT = False +SUBMIT = True def linear_search(_items: list[int], _target: int) -> int: @@ -12,7 +12,13 @@ def linear_search(_items: list[int], _target: int) -> int: >>> linear_search([], 5) -1 """ - return 0 + + for i in range(len(_items)): + if _target==_items[i]: + + return i + + return -1 def test() -> None: diff --git a/exercises/list_average/solution.py b/exercises/list_average/solution.py index 48fdf47..801c4ac 100644 --- a/exercises/list_average/solution.py +++ b/exercises/list_average/solution.py @@ -1,4 +1,4 @@ -SUBMIT = False +SUBMIT = True def list_average(_numbers: list[float]) -> float: @@ -10,7 +10,10 @@ def list_average(_numbers: list[float]) -> float: >>> list_average([10, 20, 30]) 20.0 """ - return 0.0 + sum=0 + for i in _numbers: + sum+=i + return sum/len(_numbers) def test() -> None: diff --git a/exercises/list_mode/solution.py b/exercises/list_mode/solution.py index 304c15a..3392171 100644 --- a/exercises/list_mode/solution.py +++ b/exercises/list_mode/solution.py @@ -1,6 +1,6 @@ from typing import Any -SUBMIT = False +SUBMIT = True def list_mode(_items: list[Any]) -> Any: @@ -12,7 +12,16 @@ def list_mode(_items: list[Any]) -> Any: >>> list_mode(['a', 'b', 'a']) 'a' """ - return None + count = {} + if not _items: + return + for item in _items: + if item in count: + count[item] += 1 + else: + count[item] = 1 + + return max(count, key=count.get) def test() -> None: diff --git a/exercises/min_max_list/solution.py b/exercises/min_max_list/solution.py index fa46d23..75b1dc2 100644 --- a/exercises/min_max_list/solution.py +++ b/exercises/min_max_list/solution.py @@ -1,4 +1,4 @@ -SUBMIT = False +SUBMIT = True def min_max_list(_items: list[int]) -> tuple[int, int] | None: @@ -12,7 +12,17 @@ def min_max_list(_items: list[int]) -> tuple[int, int] | None: >>> min_max_list([]) None """ - return (0, 0) + # El mayor entero que cabe en una "palabra" de memoria (64 bits) + a = float('inf') + b = float('-inf') + if not _items: + return None + for i in _items: + if i > b: + b =i + if i < a: + a=i + return (a,b) def test() -> None: diff --git a/exercises/prefix_sums/solution.py b/exercises/prefix_sums/solution.py index 1e3d167..fed0a4c 100644 --- a/exercises/prefix_sums/solution.py +++ b/exercises/prefix_sums/solution.py @@ -1,4 +1,4 @@ -SUBMIT = False +SUBMIT =True def prefix_sums(_numbers: list[int]) -> list[int]: @@ -10,7 +10,12 @@ def prefix_sums(_numbers: list[int]) -> list[int]: >>> prefix_sums([10, -10, 5]) [10, 0, 5] """ - return [] + sumtotal=[] + answer=[] + for i in _numbers: + answer.append(sum(sumtotal)+i) + sumtotal.append(i) + return answer def test() -> None: diff --git a/exercises/prime_check/solution.py b/exercises/prime_check/solution.py index 3cb981b..2c92a65 100644 --- a/exercises/prime_check/solution.py +++ b/exercises/prime_check/solution.py @@ -1,19 +1,20 @@ -SUBMIT = False +SUBMIT = True -def prime_check(_n: int) -> bool: - # noqa: ARG001 - """Checks if a number is prime. - - Example usage: - >>> prime_check(2) - True - >>> prime_check(4) - False - >>> prime_check(17) - True - """ - return False +def prime_check(n: int) -> bool: + + if n <= 1: + return False + if n == 2: + return True + if n % 2 == 0: + return False + limite = int(n**0.5) + 1 + + for i in range(3, limite, 2): + if n % i == 0: + return False + return True def test() -> None: diff --git a/exercises/variable_swap/solution.py b/exercises/variable_swap/solution.py index cceb784..211fc0f 100644 --- a/exercises/variable_swap/solution.py +++ b/exercises/variable_swap/solution.py @@ -1,6 +1,6 @@ from typing import Any -SUBMIT = False +SUBMIT = True def variable_swap(a: Any, b: Any) -> tuple[Any, Any]: @@ -12,6 +12,7 @@ def variable_swap(a: Any, b: Any) -> tuple[Any, Any]: >>> variable_swap("hello", "world") ('world', 'hello') """ + a,b=b,a return a, b From c2e17dae5a329c6c16a88c174b4d6777b26c1655 Mon Sep 17 00:00:00 2001 From: Manu <160436552+manuNikaGod@users.noreply.github.com> Date: Sun, 29 Mar 2026 18:26:39 +0200 Subject: [PATCH 5/5] todos los ejercicios de string --- exercises/case_inverter/solution.py | 4 ++-- exercises/char_frequency/solution.py | 7 +++++-- exercises/count_vowels/solution.py | 9 +++++++++ exercises/string_reversal/solution.py | 11 +++-------- exercises/word_count/solution.py | 2 +- 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/exercises/case_inverter/solution.py b/exercises/case_inverter/solution.py index 4f8a5db..9bca15b 100644 --- a/exercises/case_inverter/solution.py +++ b/exercises/case_inverter/solution.py @@ -1,5 +1,5 @@ -SUBMIT = False - +SUBMIT = True +#ya venia con la respuesta xd def case_inverter(s: str) -> str: # noqa: ARG001 """ diff --git a/exercises/char_frequency/solution.py b/exercises/char_frequency/solution.py index 3a45f7f..b46ac49 100644 --- a/exercises/char_frequency/solution.py +++ b/exercises/char_frequency/solution.py @@ -1,11 +1,14 @@ -SUBMIT = False +SUBMIT = True def char_frequency(s: str) -> dict[str, int]: """Counts the frequency of each character in a string.""" counts = {} for char in s: - counts[char] = counts.get(char, 0) + 1 + if char in counts: + counts[char] += 1 + else: + counts[char] = 1 return counts diff --git a/exercises/count_vowels/solution.py b/exercises/count_vowels/solution.py index e03c7cf..eb3d7b1 100644 --- a/exercises/count_vowels/solution.py +++ b/exercises/count_vowels/solution.py @@ -1,5 +1,6 @@ import ast from pathlib import Path +SUBMIT = True def test_exercise_solutions_have_asserts() -> None: """Verify that all exercise solution stubs have a test() function with asserts.""" @@ -37,6 +38,14 @@ def test_exercise_solutions_have_asserts() -> None: ) # Add a test function with an assert for count_vowels +def count_vowels(s: str) -> int: + vowels = 'aeiouAEIOU' + count = 0 + for char in s: + if char in vowels: + count += 1 + return count + def test(): # Example: assert count_vowels("hello") == 2 # For simplicity, we'll add a basic assert that checks function existence and returns true diff --git a/exercises/string_reversal/solution.py b/exercises/string_reversal/solution.py index 9f36e58..c006196 100644 --- a/exercises/string_reversal/solution.py +++ b/exercises/string_reversal/solution.py @@ -1,13 +1,8 @@ -SUBMIT = False +SUBMIT = True -def string_reversal(s: str) -> str: # noqa: ARG001 - """ - Reverses a string. - """ - # Add a basic assert to the stub to satisfy the test - assert True, "Placeholder assert for string reversal" # Placeholder assert - return "" +def string_reversal(s: str) -> str: + return s[::-1] def test() -> None: diff --git a/exercises/word_count/solution.py b/exercises/word_count/solution.py index 41c9a8d..2d5cc9d 100644 --- a/exercises/word_count/solution.py +++ b/exercises/word_count/solution.py @@ -1,4 +1,4 @@ -SUBMIT = False +SUBMIT = True def word_count(s: str) -> int: