From 8b2877a81e892d87801193ff057ac54c6a6466ab Mon Sep 17 00:00:00 2001 From: Efe furkan two <137198431+RDEV521@users.noreply.github.com> Date: Tue, 15 Sep 2026 08:07:06 +0300 Subject: [PATCH 01/11] Fix welcome message to reflect RDEV521 --- scripts/rdev521_hello.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 scripts/rdev521_hello.py diff --git a/scripts/rdev521_hello.py b/scripts/rdev521_hello.py new file mode 100644 index 000000000000..99c0278aee15 --- /dev/null +++ b/scripts/rdev521_hello.py @@ -0,0 +1,8 @@ +def hello_rocy() -> None: + """ + Prints a welcome message from RDEV521. + """ + print("Hello Open Source World from RDEV521!") + +if __name__ == "__main__": + hello_rocy() From 6f79d7c04927e9c0e2ec3d8c1b22041235ce11d2 Mon Sep 17 00:00:00 2001 From: Efe furkan two <137198431+RDEV521@users.noreply.github.com> Date: Tue, 15 Sep 2026 08:17:11 +0300 Subject: [PATCH 02/11] Implement Kaprekar routine for 4-digit numbers Replaced hello_rocy function with kaprekar_routine to compute steps to Kaprekar's constant (6174) for 4-digit numbers. Added input validation and a loop to perform the Kaprekar routine. --- scripts/rdev521_hello.py | 47 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/scripts/rdev521_hello.py b/scripts/rdev521_hello.py index 99c0278aee15..abff4ff513f2 100644 --- a/scripts/rdev521_hello.py +++ b/scripts/rdev521_hello.py @@ -1,8 +1,47 @@ -def hello_rocy() -> None: +def kaprekar_routine(number: int) -> int: """ - Prints a welcome message from RDEV521. + 4 basamaklı sayıları alıp Kaprekar sabitine (6174) kaç adımda ulaştığını buluyorum. + >>> kaprekar_routine(3524) + 3 + >>> kaprekar_routine(6174) + 0 """ - print("Hello Open Source World from RDEV521!") + # Sayı 4 basamaklı değilse direkt hata fırlatıyorum + if not (1000 <= number <= 9999): + raise ValueError("Sayı kesinlikle 4 basamaklı olmalı!") + + # Herkes aynı rakamı girerse (1111 gibi) döngü patlar, o yüzden engelliiyorum + if len(set(str(number))) < 2: + raise ValueError("Rakamların hepsi aynı olamaz! , en az ikisi farklı olmalı") + + kaprekar_target = 6174 + steps = 0 + + # Sayı 6174 olana kadar buradayız , döngü dönüyor + while number != kaprekar_target: + # Sayıyı 4 basamağa tamamlayıp stringe çeviriyom + digits = f"{number:04d}" + + # Rakamları büyükten küçüğe dizip birleştiriyorum + descending = int("".join(sorted(digits, reverse=True))) + + # Rakamları küçükten büyüğe dizip birleştiriyom + ascending = int("".join(sorted(digits))) + + # Büyükten küçüğü çıkarıp yeni sayıyı buluyom ve adımı arttırıyorum + number = descending - ascending + steps += 1 + + # Olur da patlarsak diye sonsuz döngü koruması koydum, en fazla 7 döner + if steps > 7: + break + + return steps if __name__ == "__main__": - hello_rocy() + import doctest + # Botların kontrol ettiği test motorunu çalıştırıyom bro + doctest.testmod() + + # Kendim test etmek için de şuraya bir örnek bıraktım + print(f"Bizim sayı tam {kaprekar_routine(3524)} adımda kilitlendi!") From 01c5d91b917bd21369fc2e965c7aaac30bfdd56a Mon Sep 17 00:00:00 2001 From: Efe furkan two <137198431+RDEV521@users.noreply.github.com> Date: Tue, 15 Sep 2026 08:20:26 +0300 Subject: [PATCH 03/11] Update rdev521_hello.py --- scripts/rdev521_hello.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/rdev521_hello.py b/scripts/rdev521_hello.py index abff4ff513f2..648bc1a71db0 100644 --- a/scripts/rdev521_hello.py +++ b/scripts/rdev521_hello.py @@ -1,6 +1,7 @@ def kaprekar_routine(number: int) -> int: """ 4 basamaklı sayıları alıp Kaprekar sabitine (6174) kaç adımda ulaştığını buluyorum. + Daha fazla bilgi için link : https://wikipedia.org >>> kaprekar_routine(3524) 3 >>> kaprekar_routine(6174) From 031dc384c32ca903fa2d92a66318841561c601a5 Mon Sep 17 00:00:00 2001 From: Efe furkan two <137198431+RDEV521@users.noreply.github.com> Date: Tue, 15 Sep 2026 08:21:24 +0300 Subject: [PATCH 04/11] Add kaprekar_constant.py script --- scripts/{rdev521_hello.py => maths/kaprekar_constant.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename scripts/{rdev521_hello.py => maths/kaprekar_constant.py} (100%) diff --git a/scripts/rdev521_hello.py b/scripts/maths/kaprekar_constant.py similarity index 100% rename from scripts/rdev521_hello.py rename to scripts/maths/kaprekar_constant.py From c5c43a0990b19288324c1ebb34951ea2f854d789 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 15 Sep 2026 05:23:48 +0000 Subject: [PATCH 05/11] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/maths/kaprekar_constant.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/maths/kaprekar_constant.py b/scripts/maths/kaprekar_constant.py index 648bc1a71db0..62a84db7be82 100644 --- a/scripts/maths/kaprekar_constant.py +++ b/scripts/maths/kaprekar_constant.py @@ -10,7 +10,7 @@ def kaprekar_routine(number: int) -> int: # Sayı 4 basamaklı değilse direkt hata fırlatıyorum if not (1000 <= number <= 9999): raise ValueError("Sayı kesinlikle 4 basamaklı olmalı!") - + # Herkes aynı rakamı girerse (1111 gibi) döngü patlar, o yüzden engelliiyorum if len(set(str(number))) < 2: raise ValueError("Rakamların hepsi aynı olamaz! , en az ikisi farklı olmalı") @@ -22,13 +22,13 @@ def kaprekar_routine(number: int) -> int: while number != kaprekar_target: # Sayıyı 4 basamağa tamamlayıp stringe çeviriyom digits = f"{number:04d}" - + # Rakamları büyükten küçüğe dizip birleştiriyorum descending = int("".join(sorted(digits, reverse=True))) - + # Rakamları küçükten büyüğe dizip birleştiriyom ascending = int("".join(sorted(digits))) - + # Büyükten küçüğü çıkarıp yeni sayıyı buluyom ve adımı arttırıyorum number = descending - ascending steps += 1 @@ -39,10 +39,12 @@ def kaprekar_routine(number: int) -> int: return steps + if __name__ == "__main__": import doctest + # Botların kontrol ettiği test motorunu çalıştırıyom bro doctest.testmod() - + # Kendim test etmek için de şuraya bir örnek bıraktım print(f"Bizim sayı tam {kaprekar_routine(3524)} adımda kilitlendi!") From 1cbe3bfa36088fa99c64f2b8e451e91cdf7ebdec Mon Sep 17 00:00:00 2001 From: Efe furkan two <137198431+RDEV521@users.noreply.github.com> Date: Tue, 15 Sep 2026 09:11:38 +0300 Subject: [PATCH 06/11] Update kaprekar_constant.py --- scripts/maths/kaprekar_constant.py | 44 +++++++++++++++--------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/scripts/maths/kaprekar_constant.py b/scripts/maths/kaprekar_constant.py index 62a84db7be82..8d29c9219df3 100644 --- a/scripts/maths/kaprekar_constant.py +++ b/scripts/maths/kaprekar_constant.py @@ -1,50 +1,50 @@ def kaprekar_routine(number: int) -> int: """ - 4 basamaklı sayıları alıp Kaprekar sabitine (6174) kaç adımda ulaştığını buluyorum. - Daha fazla bilgi için link : https://wikipedia.org + Taking 4-digit numbers and finding how many steps to reach Kaprekar constant (6174) bro. + More info link for the bots bro: https://wikipedia.org + + Keeping these here for the automatic test bots, don't mind me: >>> kaprekar_routine(3524) 3 >>> kaprekar_routine(6174) 0 """ - # Sayı 4 basamaklı değilse direkt hata fırlatıyorum + # Checking if the number is 4 digits, throwing an error if not bro if not (1000 <= number <= 9999): - raise ValueError("Sayı kesinlikle 4 basamaklı olmalı!") - - # Herkes aynı rakamı girerse (1111 gibi) döngü patlar, o yüzden engelliiyorum + raise ValueError("The number must be 4 digits bro!") + + # If someone enters all same digits like 1111, loop breaks. Blocking it here if len(set(str(number))) < 2: - raise ValueError("Rakamların hepsi aynı olamaz! , en az ikisi farklı olmalı") + raise ValueError("Digits cannot be all the same bro, make at least two different!") kaprekar_target = 6174 steps = 0 - # Sayı 6174 olana kadar buradayız , döngü dönüyor + # We are here until the number becomes 6174 bro, loop keeps spinning while number != kaprekar_target: - # Sayıyı 4 basamağa tamamlayıp stringe çeviriyom + # Padding the number to 4 digits and making it a string bro digits = f"{number:04d}" - - # Rakamları büyükten küçüğe dizip birleştiriyorum + + # Sorting digits from biggest to smallest and joining them descending = int("".join(sorted(digits, reverse=True))) - - # Rakamları küçükten büyüğe dizip birleştiriyom + + # Sorting digits from smallest to biggest and joining them ascending = int("".join(sorted(digits))) - - # Büyükten küçüğü çıkarıp yeni sayıyı buluyom ve adımı arttırıyorum + + # Subtracting smallest from biggest, finding new number and increasing steps bro number = descending - ascending steps += 1 - # Olur da patlarsak diye sonsuz döngü koruması koydum, en fazla 7 döner + # Infinite loop protection just in case we break something, spins 7 times max if steps > 7: break return steps - if __name__ == "__main__": import doctest - - # Botların kontrol ettiği test motorunu çalıştırıyom bro + # Running the test engine that the bots are checking doctest.testmod() - - # Kendim test etmek için de şuraya bir örnek bıraktım - print(f"Bizim sayı tam {kaprekar_routine(3524)} adımda kilitlendi!") + + # Just a small example here to test it for myself + print(f"Our number locked in exactly {kaprekar_routine(3524)} steps bro!") From 2f3d8d81ed1ecf7afc36511aa766b28e66aef147 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 15 Sep 2026 06:13:21 +0000 Subject: [PATCH 07/11] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/maths/kaprekar_constant.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/scripts/maths/kaprekar_constant.py b/scripts/maths/kaprekar_constant.py index 8d29c9219df3..afd7f5260062 100644 --- a/scripts/maths/kaprekar_constant.py +++ b/scripts/maths/kaprekar_constant.py @@ -2,7 +2,7 @@ def kaprekar_routine(number: int) -> int: """ Taking 4-digit numbers and finding how many steps to reach Kaprekar constant (6174) bro. More info link for the bots bro: https://wikipedia.org - + Keeping these here for the automatic test bots, don't mind me: >>> kaprekar_routine(3524) 3 @@ -12,10 +12,12 @@ def kaprekar_routine(number: int) -> int: # Checking if the number is 4 digits, throwing an error if not bro if not (1000 <= number <= 9999): raise ValueError("The number must be 4 digits bro!") - + # If someone enters all same digits like 1111, loop breaks. Blocking it here if len(set(str(number))) < 2: - raise ValueError("Digits cannot be all the same bro, make at least two different!") + raise ValueError( + "Digits cannot be all the same bro, make at least two different!" + ) kaprekar_target = 6174 steps = 0 @@ -24,13 +26,13 @@ def kaprekar_routine(number: int) -> int: while number != kaprekar_target: # Padding the number to 4 digits and making it a string bro digits = f"{number:04d}" - + # Sorting digits from biggest to smallest and joining them descending = int("".join(sorted(digits, reverse=True))) - + # Sorting digits from smallest to biggest and joining them ascending = int("".join(sorted(digits))) - + # Subtracting smallest from biggest, finding new number and increasing steps bro number = descending - ascending steps += 1 @@ -41,10 +43,12 @@ def kaprekar_routine(number: int) -> int: return steps + if __name__ == "__main__": import doctest - # Running the test engine that the bots are checking + + # Running the test engine that the bots are checking doctest.testmod() - + # Just a small example here to test it for myself print(f"Our number locked in exactly {kaprekar_routine(3524)} steps bro!") From b489b80bdbf27b148d92bb1a56eaa4f246ab2288 Mon Sep 17 00:00:00 2001 From: Efe furkan two <137198431+RDEV521@users.noreply.github.com> Date: Tue, 15 Sep 2026 09:21:33 +0300 Subject: [PATCH 08/11] Update kaprekar_constant.py --- scripts/maths/kaprekar_constant.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/maths/kaprekar_constant.py b/scripts/maths/kaprekar_constant.py index afd7f5260062..d00bf1845f4e 100644 --- a/scripts/maths/kaprekar_constant.py +++ b/scripts/maths/kaprekar_constant.py @@ -1,14 +1,14 @@ def kaprekar_routine(number: int) -> int: """ - Taking 4-digit numbers and finding how many steps to reach Kaprekar constant (6174) bro. - More info link for the bots bro: https://wikipedia.org - - Keeping these here for the automatic test bots, don't mind me: + Find steps to Kaprekar constant (6174) bro. + Link: https://wikipedia.org + >>> kaprekar_routine(3524) 3 >>> kaprekar_routine(6174) 0 """ + # Checking if the number is 4 digits, throwing an error if not bro if not (1000 <= number <= 9999): raise ValueError("The number must be 4 digits bro!") From 0e41e32dd09298b7fa5f257385278bee9279126f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 15 Sep 2026 06:21:46 +0000 Subject: [PATCH 09/11] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/maths/kaprekar_constant.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/maths/kaprekar_constant.py b/scripts/maths/kaprekar_constant.py index d00bf1845f4e..5d8a08306203 100644 --- a/scripts/maths/kaprekar_constant.py +++ b/scripts/maths/kaprekar_constant.py @@ -2,7 +2,7 @@ def kaprekar_routine(number: int) -> int: """ Find steps to Kaprekar constant (6174) bro. Link: https://wikipedia.org - + >>> kaprekar_routine(3524) 3 >>> kaprekar_routine(6174) From 1e5c4edaee1b0c44eb3fb619aabb1e062ac71ff8 Mon Sep 17 00:00:00 2001 From: Efe furkan two <137198431+RDEV521@users.noreply.github.com> Date: Tue, 15 Sep 2026 09:54:45 +0300 Subject: [PATCH 10/11] Create __init__.py --- scripts/maths/__init__.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 scripts/maths/__init__.py diff --git a/scripts/maths/__init__.py b/scripts/maths/__init__.py new file mode 100644 index 000000000000..8b137891791f --- /dev/null +++ b/scripts/maths/__init__.py @@ -0,0 +1 @@ + From ce04955aa36bf1a790559070b955302f4f2591cf Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 15 Sep 2026 06:54:58 +0000 Subject: [PATCH 11/11] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/maths/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/maths/__init__.py b/scripts/maths/__init__.py index 8b137891791f..e69de29bb2d1 100644 --- a/scripts/maths/__init__.py +++ b/scripts/maths/__init__.py @@ -1 +0,0 @@ -